From 5ef25165b505f761a099e6c3bc06569cfef74f26 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 17 Sep 2020 13:29:33 +0200 Subject: vlib: show FD in 'show memory map' Type: improvement Change-Id: I04752c011e4ca58f56aa53f6ae27bae93a5c4590 Signed-off-by: Damjan Marion --- src/vlib/cli.c | 15 +++++++++++---- src/vppinfra/linux/mem.c | 1 + src/vppinfra/mem.h | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/vlib/cli.c b/src/vlib/cli.c index 223a3b71eea..6841a5b2996 100644 --- a/src/vlib/cli.c +++ b/src/vlib/cli.c @@ -882,8 +882,8 @@ show_memory_usage (vlib_main_t * vm, u8 *s = 0; int numa = -1; - s = format (s, "\n%-16s%7s%7s%7s", - "StartAddr", "size", "PageSz", "Pages"); + s = format (s, "\n%-16s%7s%5s%7s%7s", + "StartAddr", "size", "FD", "PageSz", "Pages"); while ((numa = vlib_mem_get_next_numa_node (numa)) != -1) s = format (s, " Numa%u", numa); s = format (s, " NotMap"); @@ -896,9 +896,16 @@ show_memory_usage (vlib_main_t * vm, clib_mem_get_page_stats ((void *) hdr->base_addr, hdr->log2_page_sz, hdr->num_pages, &stats); - s = format (s, "%016lx%7U%7U%7lu", + s = format (s, "%016lx%7U", hdr->base_addr, format_memory_size, - hdr->num_pages << hdr->log2_page_sz, + hdr->num_pages << hdr->log2_page_sz); + + if (hdr->fd != -1) + s = format (s, "%5d", hdr->fd); + else + s = format (s, "%5s", " "); + + s = format (s, "%7U%7lu", format_log2_page_size, hdr->log2_page_sz, hdr->num_pages); while ((numa = vlib_mem_get_next_numa_node (numa)) != -1) diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c index 96fb0db5b73..ef98b3f360b 100644 --- a/src/vppinfra/linux/mem.c +++ b/src/vppinfra/linux/mem.c @@ -579,6 +579,7 @@ clib_mem_vm_map_internal (void *base, clib_mem_page_sz_t log2_page_sz, hdr->base_addr = (uword) base; hdr->log2_page_sz = log2_page_sz; hdr->num_pages = size >> log2_page_sz; + hdr->fd = fd; snprintf (hdr->name, CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1, "%s", (char *) name); hdr->name[CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1] = 0; mprotect (hdr, sys_page_sz, PROT_NONE); diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h index e6f019cd097..9d0aa0997fc 100644 --- a/src/vppinfra/mem.h +++ b/src/vppinfra/mem.h @@ -83,6 +83,9 @@ typedef struct _clib_mem_vm_map_hdr /* page size (log2) */ clib_mem_page_sz_t log2_page_sz; + /* file descriptor, -1 if memory is not shared */ + int fd; + /* allocation mame */ #define CLIB_VM_MAP_HDR_NAME_MAX_LEN 64 char name[CLIB_VM_MAP_HDR_NAME_MAX_LEN]; -- cgit 1.2.3-korg