/* This function will return the greatest free block if a heap has been * specified. If no heap has been specified, it will return the heap and * length of the greatest free block available in all heaps */ static size_t find_heap_max_free_elem(int *s, unsigned align) { struct rte_mem_config *mcfg; struct rte_malloc_socket_stats stats; int i, socket = *s; size_t len = 0; /* get pointer to global configuration */ mcfg = rte_eal_get_configuration()->mem_config; for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { if ((socket != SOCKET_ID_ANY) && (socket != i)) continue; malloc_heap_get_stats(&mcfg->malloc_heaps[i], &stats); if (stats.greatest_free_size > len) { len = stats.greatest_free_size; *s = i; } } if (len < MALLOC_ELEM_OVERHEAD + align) return 0; return len - MALLOC_ELEM_OVERHEAD - align; }
/* * Function to retrieve data for heap on given socket */ int rte_malloc_get_socket_stats(int socket, struct rte_malloc_socket_stats *socket_stats) { struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; if (socket >= RTE_MAX_NUMA_NODES || socket < 0) return -1; return malloc_heap_get_stats(&mcfg->malloc_heaps[socket], socket_stats); }