MCPcopy Create free account
hub / github.com/F-Stack/f-stack / alloc_seg_walk

Function alloc_seg_walk

dpdk/lib/eal/windows/eal_memalloc.c:178–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176};
177
178static int
179alloc_seg_walk(const struct rte_memseg_list *msl, void *arg)
180{
181 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
182 struct alloc_walk_param *wa = arg;
183 struct rte_memseg_list *cur_msl;
184 size_t page_sz;
185 int cur_idx, start_idx, j;
186 unsigned int msl_idx, need, i;
187
188 if (msl->page_sz != wa->page_sz)
189 return 0;
190 if (msl->socket_id != wa->socket)
191 return 0;
192
193 page_sz = (size_t)msl->page_sz;
194
195 msl_idx = msl - mcfg->memsegs;
196 cur_msl = &mcfg->memsegs[msl_idx];
197
198 need = wa->n_segs;
199
200 /* try finding space in memseg list */
201 if (wa->exact) {
202 /* if we require exact number of pages in a list, find them */
203 cur_idx = rte_fbarray_find_next_n_free(
204 &cur_msl->memseg_arr, 0, need);
205 if (cur_idx < 0)
206 return 0;
207 start_idx = cur_idx;
208 } else {
209 int cur_len;
210
211 /* we don't require exact number of pages, so we're going to go
212 * for best-effort allocation. that means finding the biggest
213 * unused block, and going with that.
214 */
215 cur_idx = rte_fbarray_find_biggest_free(
216 &cur_msl->memseg_arr, 0);
217 if (cur_idx < 0)
218 return 0;
219 start_idx = cur_idx;
220 /* adjust the size to possibly be smaller than original
221 * request, but do not allow it to be bigger.
222 */
223 cur_len = rte_fbarray_find_contig_free(
224 &cur_msl->memseg_arr, cur_idx);
225 need = RTE_MIN(need, (unsigned int)cur_len);
226 }
227
228 for (i = 0; i < need; i++, cur_idx++) {
229 struct rte_memseg *cur;
230 void *map_addr;
231
232 cur = rte_fbarray_get(&cur_msl->memseg_arr, cur_idx);
233 map_addr = RTE_PTR_ADD(cur_msl->base_va, cur_idx * page_sz);
234
235 if (alloc_seg(cur, map_addr, wa->socket, wa->hi)) {

Callers

nothing calls this directly

Calls 10

rte_fbarray_getFunction · 0.85
rte_fbarray_set_freeFunction · 0.85
memsetFunction · 0.85
rte_fbarray_set_usedFunction · 0.85
alloc_segFunction · 0.70
free_segFunction · 0.70

Tested by

no test coverage detected