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

Function alloc_more_mem_on_socket

dpdk/lib/eal/common/malloc_heap.c:534–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532}
533
534static int
535alloc_more_mem_on_socket(struct malloc_heap *heap, size_t size, int socket,
536 unsigned int flags, size_t align, size_t bound, bool contig)
537{
538 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
539 struct rte_memseg_list *requested_msls[RTE_MAX_MEMSEG_LISTS];
540 struct rte_memseg_list *other_msls[RTE_MAX_MEMSEG_LISTS];
541 uint64_t requested_pg_sz[RTE_MAX_MEMSEG_LISTS];
542 uint64_t other_pg_sz[RTE_MAX_MEMSEG_LISTS];
543 uint64_t prev_pg_sz;
544 int i, n_other_msls, n_other_pg_sz, n_requested_msls, n_requested_pg_sz;
545 bool size_hint = (flags & RTE_MEMZONE_SIZE_HINT_ONLY) > 0;
546 unsigned int size_flags = flags & ~RTE_MEMZONE_SIZE_HINT_ONLY;
547 void *ret;
548
549 memset(requested_msls, 0, sizeof(requested_msls));
550 memset(other_msls, 0, sizeof(other_msls));
551 memset(requested_pg_sz, 0, sizeof(requested_pg_sz));
552 memset(other_pg_sz, 0, sizeof(other_pg_sz));
553
554 /*
555 * go through memseg list and take note of all the page sizes available,
556 * and if any of them were specifically requested by the user.
557 */
558 n_requested_msls = 0;
559 n_other_msls = 0;
560 for (i = 0; i < RTE_MAX_MEMSEG_LISTS; i++) {
561 struct rte_memseg_list *msl = &mcfg->memsegs[i];
562
563 if (msl->socket_id != socket)
564 continue;
565
566 if (msl->base_va == NULL)
567 continue;
568
569 /* if pages of specific size were requested */
570 if (size_flags != 0 && check_hugepage_sz(size_flags,
571 msl->page_sz))
572 requested_msls[n_requested_msls++] = msl;
573 else if (size_flags == 0 || size_hint)
574 other_msls[n_other_msls++] = msl;
575 }
576
577 /* sort the lists, smallest first */
578 qsort(requested_msls, n_requested_msls, sizeof(requested_msls[0]),
579 compare_pagesz);
580 qsort(other_msls, n_other_msls, sizeof(other_msls[0]),
581 compare_pagesz);
582
583 /* now, extract page sizes we are supposed to try */
584 prev_pg_sz = 0;
585 n_requested_pg_sz = 0;
586 for (i = 0; i < n_requested_msls; i++) {
587 uint64_t pg_sz = requested_msls[i]->page_sz;
588
589 if (prev_pg_sz != pg_sz) {
590 requested_pg_sz[n_requested_pg_sz++] = pg_sz;
591 prev_pg_sz = pg_sz;

Callers 1

Calls 6

memsetFunction · 0.85
check_hugepage_szFunction · 0.85
qsortFunction · 0.85
try_expand_heapFunction · 0.85
find_suitable_elementFunction · 0.85

Tested by

no test coverage detected