Dump the socket memory statistics on console */
| 8359 | |
| 8360 | /* Dump the socket memory statistics on console */ |
| 8361 | static void |
| 8362 | dump_socket_mem(FILE *f) |
| 8363 | { |
| 8364 | struct rte_malloc_socket_stats socket_stats; |
| 8365 | unsigned int i; |
| 8366 | size_t total = 0; |
| 8367 | size_t alloc = 0; |
| 8368 | size_t free = 0; |
| 8369 | unsigned int n_alloc = 0; |
| 8370 | unsigned int n_free = 0; |
| 8371 | static size_t last_allocs; |
| 8372 | static size_t last_total; |
| 8373 | |
| 8374 | |
| 8375 | for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { |
| 8376 | if (rte_malloc_get_socket_stats(i, &socket_stats) || |
| 8377 | !socket_stats.heap_totalsz_bytes) |
| 8378 | continue; |
| 8379 | total += socket_stats.heap_totalsz_bytes; |
| 8380 | alloc += socket_stats.heap_allocsz_bytes; |
| 8381 | free += socket_stats.heap_freesz_bytes; |
| 8382 | n_alloc += socket_stats.alloc_count; |
| 8383 | n_free += socket_stats.free_count; |
| 8384 | fprintf(f, |
| 8385 | "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", |
| 8386 | i, |
| 8387 | (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), |
| 8388 | (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), |
| 8389 | (double)socket_stats.heap_allocsz_bytes * 100 / |
| 8390 | (double)socket_stats.heap_totalsz_bytes, |
| 8391 | (double)socket_stats.heap_freesz_bytes / (1024 * 1024), |
| 8392 | socket_stats.alloc_count, |
| 8393 | socket_stats.free_count); |
| 8394 | } |
| 8395 | fprintf(f, |
| 8396 | "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", |
| 8397 | (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), |
| 8398 | total ? ((double)alloc * 100 / (double)total) : 0, |
| 8399 | (double)free / (1024 * 1024), |
| 8400 | n_alloc, n_free); |
| 8401 | if (last_allocs) |
| 8402 | fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", |
| 8403 | ((double)total - (double)last_total) / (1024 * 1024), |
| 8404 | (double)(alloc - (double)last_allocs) / 1024 / 1024); |
| 8405 | last_allocs = alloc; |
| 8406 | last_total = total; |
| 8407 | } |
| 8408 | |
| 8409 | static void cmd_dump_parsed(void *parsed_result, |
| 8410 | __rte_unused struct cmdline *cl, |
no test coverage detected