| 701 | } |
| 702 | |
| 703 | static unsigned int |
| 704 | malloc_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 | |
| 732 | void * |
| 733 | malloc_heap_alloc(const char *type, size_t size, int socket_arg, |
no test coverage detected