| 730 | } |
| 731 | |
| 732 | void * |
| 733 | malloc_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 | |
| 776 | static void * |
| 777 | heap_alloc_biggest_on_heap_id(const char *type, unsigned int heap_id, |
no test coverage detected