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

Function malloc_heap_alloc

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

Source from the content-addressed store, hash-verified

730}
731
732void *
733malloc_heap_alloc(const char *type, size_t size, int socket_arg,
734 unsigned int flags, size_t align, size_t bound, bool contig)
735{
736 int socket, heap_id, i;
737 void *ret;
738
739 /* return NULL if size is 0 or alignment is not power-of-2 */
740 if (size == 0 || (align && !rte_is_power_of_2(align)))
741 return NULL;
742
743 if (!rte_eal_has_hugepages() && socket_arg < RTE_MAX_NUMA_NODES)
744 socket_arg = SOCKET_ID_ANY;
745
746 if (socket_arg == SOCKET_ID_ANY)
747 socket = malloc_get_numa_socket();
748 else
749 socket = socket_arg;
750
751 /* turn socket ID into heap ID */
752 heap_id = malloc_socket_to_heap_id(socket);
753 /* if heap id is negative, socket ID was invalid */
754 if (heap_id < 0)
755 return NULL;
756
757 ret = malloc_heap_alloc_on_heap_id(type, size, heap_id, flags, align,
758 bound, contig);
759 if (ret != NULL || socket_arg != SOCKET_ID_ANY)
760 return ret;
761
762 /* try other heaps. we are only iterating through native DPDK sockets,
763 * so external heaps won't be included.
764 */
765 for (i = 0; i < (int) rte_socket_count(); i++) {
766 if (i == heap_id)
767 continue;
768 ret = malloc_heap_alloc_on_heap_id(type, size, i, flags, align,
769 bound, contig);
770 if (ret != NULL)
771 return ret;
772 }
773 return NULL;
774}
775
776static void *
777heap_alloc_biggest_on_heap_id(const char *type, unsigned int heap_id,

Callers 2

malloc_socketFunction · 0.85

Calls 6

rte_eal_has_hugepagesFunction · 0.85
malloc_get_numa_socketFunction · 0.85
malloc_socket_to_heap_idFunction · 0.85
rte_socket_countFunction · 0.85
rte_is_power_of_2Function · 0.50

Tested by

no test coverage detected