Show ioremap and vmap in /proc/meminfo
PATCH 1/1 Show ioremap and vmap in /proc/meminfo
Hi,
For long time I've been thought the following equation is correct:
The "MemUsage" is about "Active + Inactive + Slab + PageTables + VmallocUsed" in /proc/meminfo.
(I'm not only the person. See https://bugzilla.redhat.com/show_bug.cgi?id=243657.)
However, some VmallocUsed doesn't really consume MemUsage: ioremap pages and vmap pages consume just virtual address spaces.
It is a bit helpful for people who want to understand kernel memory usage to show the number of ioremap and vmap pages in /proc/meminfo.
The following patch adds entries for ioremap and vmap to /proc/meminfo.
fs/proc/internal.h +4 -0
@@ -19,6 +19,8 @@ static inline void proc_sys_init(void) { }struct vmalloc_info {unsigned long used; +unsigned long used_as_ioremap; +unsigned long used_as_vmap;unsigned long largest_chunk; };
@@ -31,6 +33,8 @@ extern void get_vmalloc_info(struct vmalloc_info *vmi);#define get_vmalloc_info (vmi) \ do { \ (vmi)->used = 0; \ + (vmi)->used_as_ioremap = 0; \ + (vmi)->used_as_vmap = 0; \ (vmi)->largest_chunk = 0; \ } while(0)
fs/proc/mmu.c +14 -3
@@ -38,7 +38,9 @@ void get_vmalloc_info(struct vmalloc_info *vmi)unsigned long prev_end; vmi->used =0 ; - + vmi->used_as_ioremap =0 ; + vmi->used_as_vmap =0 ; +if (!vmlist) { vmi->largest_chunk =VMALLOC_TOTAL ; }
@@ -51,6 +53,8 @@ void get_vmalloc_info(struct vmalloc_info *vmi)for (vma = vmlist; vma; vma = vma->next) {unsigned long addr = (unsigned long ) vma->addr; +unsigned long flags; +unsigned long size;/* * Some archs keep another range for modules in vmlist
@@ -59,8 +63,15 @@ void get_vmalloc_info(struct vmalloc_info *vmi)continue ;if (addr >=VMALLOC_END )break ; - - vmi->used += vma->size; + + size = vma->size; + flags = vma->flags; + + vmi->used += size; +if (flags &VM_IOREMAP ) + vmi->used_as_ioremap += size; +if (flags &VM_MAP ) + vmi->used_as_vmap += size; free_area_size = addr - prev_end;if (vmi->largest_chunk < free_area_size)
fs/proc/proc_misc.c +4 -0
@@ -176,6 +176,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,"Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" +"IORemapUsed: %8lu kB\n" +"VmapUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n" ,K (i.totalram), K(i.freeram),
@@ -207,6 +209,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,K (committed), (unsigned long )VMALLOC_TOTAL >>10 , vmi.used >>10 , + vmi.used_as_ioremap >>10 , + vmi.used_as_vmap >>10 , vmi.largest_chunk >>10 );
Hi,
The patch I posted has not got any response.
Do you think ioremap and vmap information in /proc/meminfo is not useful? or are you just busy?
<the original message>
Hi,
For long time I've been thought the following equation is correct:
The "MemUsage" is about "Active + Inactive + Slab + PageTables + VmallocUsed" in /proc/meminfo.
(I'm not only the person. See https://bugzilla.redhat.com/show_bug.cgi?id=243657.)
However, some VmallocUsed doesn't really consume MemUsage: ioremap pages and vmap pages consume just virtual address spaces.
It is a bit helpful for people who want to understand kernel memory usage to show the number of ioremap and vmap pages in /proc/meminfo.
The following patch adds entries for ioremap and vmap to /proc/meminfo.
fs/proc/internal.h +4 -0
@@ -19,6 +19,8 @@ static inline void proc_sys_init(void) { }struct vmalloc_info {unsigned long used; +unsigned long used_as_ioremap; +unsigned long used_as_vmap;unsigned long largest_chunk; };
@@ -31,6 +33,8 @@ extern void get_vmalloc_info(struct vmalloc_info *vmi);#define get_vmalloc_info (vmi) \ do { \ (vmi)->used = 0; \ + (vmi)->used_as_ioremap = 0; \ + (vmi)->used_as_vmap = 0; \ (vmi)->largest_chunk = 0; \ } while(0)
fs/proc/mmu.c +14 -3
@@ -38,7 +38,9 @@ void get_vmalloc_info(struct vmalloc_info *vmi)unsigned long prev_end; vmi->used =0 ; - + vmi->used_as_ioremap =0 ; + vmi->used_as_vmap =0 ; +if (!vmlist) { vmi->largest_chunk =VMALLOC_TOTAL ; }
@@ -51,6 +53,8 @@ void get_vmalloc_info(struct vmalloc_info *vmi)for (vma = vmlist; vma; vma = vma->next) {unsigned long addr = (unsigned long ) vma->addr; +unsigned long flags; +unsigned long size;/* * Some archs keep another range for modules in vmlist
@@ -59,8 +63,15 @@ void get_vmalloc_info(struct vmalloc_info *vmi)continue ;if (addr >=VMALLOC_END )break ; - - vmi->used += vma->size; + + size = vma->size; + flags = vma->flags; + + vmi->used += size; +if (flags &VM_IOREMAP ) + vmi->used_as_ioremap += size; +if (flags &VM_MAP ) + vmi->used_as_vmap += size; free_area_size = addr - prev_end;if (vmi->largest_chunk < free_area_size)
fs/proc/proc_misc.c +4 -0
@@ -176,6 +176,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,"Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" +"IORemapUsed: %8lu kB\n" +"VmapUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n" ,K (i.totalram), K(i.freeram),
@@ -207,6 +209,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,K (committed), (unsigned long )VMALLOC_TOTAL >>10 , vmi.used >>10 , + vmi.used_as_ioremap >>10 , + vmi.used_as_vmap >>10 , vmi.largest_chunk >>10 );