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

Function malloc_heap_alloc_biggest

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

Source from the content-addressed store, hash-verified

793}
794
795void *
796malloc_heap_alloc_biggest(const char *type, int socket_arg, unsigned int flags,
797 size_t align, bool contig)
798{
799 int socket, i, cur_socket, heap_id;
800 void *ret;
801
802 /* return NULL if align is not power-of-2 */
803 if ((align && !rte_is_power_of_2(align)))
804 return NULL;
805
806 if (!rte_eal_has_hugepages())
807 socket_arg = SOCKET_ID_ANY;
808
809 if (socket_arg == SOCKET_ID_ANY)
810 socket = malloc_get_numa_socket();
811 else
812 socket = socket_arg;
813
814 /* turn socket ID into heap ID */
815 heap_id = malloc_socket_to_heap_id(socket);
816 /* if heap id is negative, socket ID was invalid */
817 if (heap_id < 0)
818 return NULL;
819
820 ret = heap_alloc_biggest_on_heap_id(type, heap_id, flags, align,
821 contig);
822 if (ret != NULL || socket_arg != SOCKET_ID_ANY)
823 return ret;
824
825 /* try other heaps */
826 for (i = 0; i < (int) rte_socket_count(); i++) {
827 cur_socket = rte_socket_id_by_idx(i);
828 if (cur_socket == socket)
829 continue;
830 ret = heap_alloc_biggest_on_heap_id(type, i, flags, align,
831 contig);
832 if (ret != NULL)
833 return ret;
834 }
835 return NULL;
836}
837
838/* this function is exposed in malloc_mp.h */
839int

Callers 1

Calls 7

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_socket_id_by_idxFunction · 0.85
rte_is_power_of_2Function · 0.50

Tested by

no test coverage detected