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

Function map_all_hugepages

dpdk/lib/eal/linux/eal_memory.c:263–420  ·  view source on GitHub ↗

* Mmap all hugepages of hugepage table: it first open a file in * hugetlbfs, then mmap() hugepage_sz data in it. If orig is set, the * virtual address is stored in hugepg_tbl[i].orig_va, else it is stored * in hugepg_tbl[i].final_va. The second mapping (when orig is 0) tries to * map contiguous physical blocks in contiguous virtual blocks. */

Source from the content-addressed store, hash-verified

261 * map contiguous physical blocks in contiguous virtual blocks.
262 */
263static unsigned
264map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
265 uint64_t *essential_memory __rte_unused)
266{
267 int fd;
268 unsigned i;
269 void *virtaddr;
270#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES
271 int node_id = -1;
272 int essential_prev = 0;
273 int oldpolicy;
274 struct bitmask *oldmask = NULL;
275 bool have_numa = true;
276 unsigned long maxnode = 0;
277 const struct internal_config *internal_conf =
278 eal_get_internal_configuration();
279
280 /* Check if kernel supports NUMA. */
281 if (numa_available() != 0) {
282 RTE_LOG(DEBUG, EAL, "NUMA is not supported.\n");
283 have_numa = false;
284 }
285
286 if (have_numa) {
287 RTE_LOG(DEBUG, EAL, "Trying to obtain current memory policy.\n");
288 oldmask = numa_allocate_nodemask();
289 if (get_mempolicy(&oldpolicy, oldmask->maskp,
290 oldmask->size + 1, 0, 0) < 0) {
291 RTE_LOG(ERR, EAL,
292 "Failed to get current mempolicy: %s. "
293 "Assuming MPOL_DEFAULT.\n", strerror(errno));
294 oldpolicy = MPOL_DEFAULT;
295 }
296 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
297 if (internal_conf->socket_mem[i])
298 maxnode = i + 1;
299 }
300#endif
301
302 for (i = 0; i < hpi->num_pages[0]; i++) {
303 struct hugepage_file *hf = &hugepg_tbl[i];
304 uint64_t hugepage_sz = hpi->hugepage_sz;
305
306#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES
307 if (maxnode) {
308 unsigned int j;
309
310 for (j = 0; j < maxnode; j++)
311 if (essential_memory[j])
312 break;
313
314 if (j == maxnode) {
315 node_id = (node_id + 1) % maxnode;
316 while (!internal_conf->socket_mem[node_id]) {
317 node_id++;
318 node_id %= maxnode;
319 }
320 essential_prev = 0;

Callers 1

eal_legacy_hugepage_initFunction · 0.85

Calls 5

eal_get_hugefile_pathFunction · 0.85
huge_wrap_sigsetjmpFunction · 0.70
flockClass · 0.70
closeFunction · 0.50

Tested by

no test coverage detected