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

Function eal_memalloc_alloc_seg_bulk

dpdk/lib/eal/linux/eal_memalloc.c:1011–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1009}
1010
1011int
1012eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,
1013 int socket, bool exact)
1014{
1015 int i, ret = -1;
1016#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES
1017 bool have_numa = false;
1018 int oldpolicy;
1019 struct bitmask *oldmask;
1020#endif
1021 struct alloc_walk_param wa;
1022 struct hugepage_info *hi = NULL;
1023 struct internal_config *internal_conf =
1024 eal_get_internal_configuration();
1025
1026 memset(&wa, 0, sizeof(wa));
1027
1028 /* dynamic allocation not supported in legacy mode */
1029 if (internal_conf->legacy_mem)
1030 return -1;
1031
1032 for (i = 0; i < (int) RTE_DIM(internal_conf->hugepage_info); i++) {
1033 if (page_sz ==
1034 internal_conf->hugepage_info[i].hugepage_sz) {
1035 hi = &internal_conf->hugepage_info[i];
1036 break;
1037 }
1038 }
1039 if (!hi) {
1040 RTE_LOG(ERR, EAL, "%s(): can't find relevant hugepage_info entry\n",
1041 __func__);
1042 return -1;
1043 }
1044
1045#ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES
1046 if (check_numa()) {
1047 oldmask = numa_allocate_nodemask();
1048 prepare_numa(&oldpolicy, oldmask, socket);
1049 have_numa = true;
1050 }
1051#endif
1052
1053 wa.exact = exact;
1054 wa.hi = hi;
1055 wa.ms = ms;
1056 wa.n_segs = n_segs;
1057 wa.page_sz = page_sz;
1058 wa.socket = socket;
1059 wa.segs_allocated = 0;
1060
1061 /* memalloc is locked, so it's safe to use thread-unsafe version */
1062 ret = rte_memseg_list_walk_thread_unsafe(alloc_seg_walk, &wa);
1063 if (ret == 0) {
1064 RTE_LOG(DEBUG, EAL, "%s(): couldn't find suitable memseg_list\n",
1065 __func__);
1066 ret = -1;
1067 } else if (ret > 0) {
1068 ret = (int)wa.segs_allocated;

Callers 3

eal_memalloc_alloc_segFunction · 0.70
eal_dynmem_hugepage_initFunction · 0.50
alloc_pages_on_heapFunction · 0.50

Calls 6

memsetFunction · 0.85
check_numaFunction · 0.85
prepare_numaFunction · 0.85
restore_numaFunction · 0.85

Tested by

no test coverage detected