From a85f36b35e84d86bf4c1b78df4faca39619f219b Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Tue, 10 Dec 2019 15:16:42 -0700 Subject: [PATCH] env: add a new function for printing memory layout This is a useful utility function. The end goal of this patch series is to create a python utility that can be called upon to dump information about DPDK allocated memory in a human readable way. Change-Id: I18978732c9decbb39dce5b5151f5eff6b59f6591 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477510 Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins Community-CI: Broadcom SPDK FC-NVMe CI Community-CI: SPDK CI Jenkins --- include/spdk/env_dpdk.h | 9 +++++++++ lib/env_dpdk/env.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/spdk/env_dpdk.h b/include/spdk/env_dpdk.h index 2240558ad..6716f323c 100644 --- a/include/spdk/env_dpdk.h +++ b/include/spdk/env_dpdk.h @@ -35,6 +35,8 @@ * Encapsulated DPDK specific dependencies */ +#include "spdk/stdinc.h" + #ifndef SPDK_ENV_DPDK_H #define SPDK_ENV_DPDK_H @@ -70,6 +72,13 @@ void spdk_env_dpdk_post_fini(void); */ bool spdk_env_dpdk_external_init(void); +/** + * Dump the env allocated memory to the given file. + * + * \param file The file object to write to. + */ +void spdk_env_dpdk_dump_mem_stats(FILE *file); + #ifdef __cplusplus } #endif diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index a5aad56a1..b10bbb5c1 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -33,6 +33,7 @@ #include "spdk/stdinc.h" #include "spdk/util.h" +#include "spdk/env_dpdk.h" #include "env_internal.h" @@ -437,3 +438,19 @@ spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count) { return rte_ring_dequeue_burst((struct rte_ring *)ring, objs, count, NULL); } + +void +spdk_env_dpdk_dump_mem_stats(FILE *file) +{ + fprintf(file, "DPDK memory size %lu\n", rte_eal_get_physmem_size()); + fprintf(file, "DPDK memory layout\n"); + rte_dump_physmem_layout(file); + fprintf(file, "DPDK memzones.\n"); + rte_memzone_dump(file); + fprintf(file, "DPDK mempools.\n"); + rte_mempool_list_dump(file); + fprintf(file, "DPDK malloc stats.\n"); + rte_malloc_dump_stats(file, NULL); + fprintf(file, "DPDK malloc heaps.\n"); + rte_malloc_dump_heaps(file); +}