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 <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477510
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Seth Howell 2019-12-10 15:16:42 -07:00 committed by Tomasz Zawadzki
parent 164151c727
commit a85f36b35e
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

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