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); +}