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

Function malloc_get_numa_socket

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

Source from the content-addressed store, hash-verified

701}
702
703static unsigned int
704malloc_get_numa_socket(void)
705{
706 const struct internal_config *conf = eal_get_internal_configuration();
707 unsigned int socket_id = rte_socket_id();
708 unsigned int idx;
709
710 if (socket_id != (unsigned int)SOCKET_ID_ANY)
711 return socket_id;
712
713 /* for control threads, return first socket where memory is available */
714 for (idx = 0; idx < rte_socket_count(); idx++) {
715 socket_id = rte_socket_id_by_idx(idx);
716 if (conf->socket_mem[socket_id] != 0)
717 return socket_id;
718 }
719 /* We couldn't quickly find a NUMA node where memory was available,
720 * so fall back to using main lcore socket ID.
721 */
722 socket_id = rte_lcore_to_socket_id(rte_get_main_lcore());
723 /* Main lcore socket ID may be SOCKET_ID_ANY
724 * when main lcore thread is affinitized to multiple NUMA nodes.
725 */
726 if (socket_id != (unsigned int)SOCKET_ID_ANY)
727 return socket_id;
728 /* Failed to find meaningful socket ID, so use the first one available. */
729 return rte_socket_id_by_idx(0);
730}
731
732void *
733malloc_heap_alloc(const char *type, size_t size, int socket_arg,

Callers 2

malloc_heap_allocFunction · 0.85

Calls 6

rte_socket_idFunction · 0.85
rte_socket_countFunction · 0.85
rte_socket_id_by_idxFunction · 0.85
rte_lcore_to_socket_idFunction · 0.85
rte_get_main_lcoreFunction · 0.85

Tested by

no test coverage detected