+/* Dump the socket memory statistics on console */
+static size_t
+dump_socket_mem(FILE *f)
+{
+ struct rte_malloc_socket_stats socket_stats;
+ unsigned int i = 0;
+ size_t total = 0;
+ size_t alloc = 0;
+ size_t free = 0;
+ unsigned int n_alloc = 0;
+ unsigned int n_free = 0;
+ bool active_nodes = false;
+
+
+ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
+ if (rte_malloc_get_socket_stats(i, &socket_stats) ||
+ !socket_stats.heap_totalsz_bytes)
+ continue;
+ active_nodes = true;
+ total += socket_stats.heap_totalsz_bytes;
+ alloc += socket_stats.heap_allocsz_bytes;
+ free += socket_stats.heap_freesz_bytes;
+ n_alloc += socket_stats.alloc_count;
+ n_free += socket_stats.free_count;
+ if (dump_socket_mem_flag) {
+ fprintf(f, "::::::::::::::::::::::::::::::::::::::::");
+ fprintf(f,
+ "\nSocket %u:\nsize(M) total: %.6lf\nalloc:"
+ " %.6lf(%.3lf%%)\nfree: %.6lf"
+ "\nmax: %.6lf"
+ "\ncount alloc: %u\nfree: %u\n",
+ i,
+ socket_stats.heap_totalsz_bytes / 1.0e6,
+ socket_stats.heap_allocsz_bytes / 1.0e6,
+ (double)socket_stats.heap_allocsz_bytes * 100 /
+ (double)socket_stats.heap_totalsz_bytes,
+ socket_stats.heap_freesz_bytes / 1.0e6,
+ socket_stats.greatest_free_size / 1.0e6,
+ socket_stats.alloc_count,
+ socket_stats.free_count);
+ fprintf(f, "::::::::::::::::::::::::::::::::::::::::");
+ }
+ }
+ if (dump_socket_mem_flag && active_nodes) {
+ fprintf(f,
+ "\nTotal: size(M)\ntotal: %.6lf"
+ "\nalloc: %.6lf(%.3lf%%)\nfree: %.6lf"
+ "\ncount alloc: %u\nfree: %u\n",
+ total / 1.0e6, alloc / 1.0e6,
+ (double)alloc * 100 / (double)total, free / 1.0e6,
+ n_alloc, n_free);
+ fprintf(f, "::::::::::::::::::::::::::::::::::::::::\n");
+ }
+ return alloc;
+}
+