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

Function malloc_add_seg

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

Source from the content-addressed store, hash-verified

104}
105
106static int
107malloc_add_seg(const struct rte_memseg_list *msl,
108 const struct rte_memseg *ms, size_t len, void *arg __rte_unused)
109{
110 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
111 struct rte_memseg_list *found_msl;
112 struct malloc_heap *heap;
113 int msl_idx, heap_idx;
114
115 if (msl->external)
116 return 0;
117
118 heap_idx = malloc_socket_to_heap_id(msl->socket_id);
119 if (heap_idx < 0) {
120 RTE_LOG(ERR, EAL, "Memseg list has invalid socket id\n");
121 return -1;
122 }
123 heap = &mcfg->malloc_heaps[heap_idx];
124
125 /* msl is const, so find it */
126 msl_idx = msl - mcfg->memsegs;
127
128 if (msl_idx < 0 || msl_idx >= RTE_MAX_MEMSEG_LISTS)
129 return -1;
130
131 found_msl = &mcfg->memsegs[msl_idx];
132
133 malloc_heap_add_memory(heap, found_msl, ms->addr, len,
134 ms->flags & RTE_MEMSEG_FLAG_DIRTY);
135
136 heap->total_size += len;
137
138 RTE_LOG(DEBUG, EAL, "Added %zuM to heap on socket %i\n", len >> 20,
139 msl->socket_id);
140 return 0;
141}
142
143/*
144 * Iterates through the freelist for a heap to find a free element

Callers

nothing calls this directly

Calls 3

malloc_socket_to_heap_idFunction · 0.85
malloc_heap_add_memoryFunction · 0.85

Tested by

no test coverage detected