+ mm-show-number-of-vmalloc-pages-in-proc-meminfo.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: vmalloc: show number of vmalloc pages in /proc/meminfo
has been added to the -mm tree.  Its filename is
     mm-show-number-of-vmalloc-pages-in-proc-meminfo.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-show-number-of-vmalloc-pages-in-proc-meminfo.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-show-number-of-vmalloc-pages-in-proc-meminfo.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Roman Gushchin <guro@xxxxxx>
Subject: mm: vmalloc: show number of vmalloc pages in /proc/meminfo

Vmalloc() is getting more and more used these days (kernel stacks, bpf and
percpu allocator are new top users), and the total % of memory consumed by
vmalloc() can be pretty significant and changes dynamically.

/proc/meminfo is the best place to display this information: its top goal
is to show top consumers of the memory.

Since the VmallocUsed field in /proc/meminfo is not in use for quite a
long time (it has been defined to 0 by a5ad88ce8c7f ("mm: get rid of
'vmalloc_info' from /proc/meminfo")), let's reuse it for showing the
actual physical memory consumption of vmalloc().

Link: http://lkml.kernel.org/r/20190417194002.12369-3-guro@xxxxxx
Signed-off-by: Roman Gushchin <guro@xxxxxx>
Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Minchan Kim <minchan@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/proc/meminfo.c       |    2 +-
 include/linux/vmalloc.h |    2 ++
 mm/vmalloc.c            |   10 ++++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

--- a/fs/proc/meminfo.c~mm-show-number-of-vmalloc-pages-in-proc-meminfo
+++ a/fs/proc/meminfo.c
@@ -120,7 +120,7 @@ static int meminfo_proc_show(struct seq_
 	show_val_kb(m, "Committed_AS:   ", committed);
 	seq_printf(m, "VmallocTotal:   %8lu kB\n",
 		   (unsigned long)VMALLOC_TOTAL >> 10);
-	show_val_kb(m, "VmallocUsed:    ", 0ul);
+	show_val_kb(m, "VmallocUsed:    ", vmalloc_nr_pages());
 	show_val_kb(m, "VmallocChunk:   ", 0ul);
 	show_val_kb(m, "Percpu:         ", pcpu_nr_pages());
 
--- a/include/linux/vmalloc.h~mm-show-number-of-vmalloc-pages-in-proc-meminfo
+++ a/include/linux/vmalloc.h
@@ -72,10 +72,12 @@ extern void vm_unmap_aliases(void);
 
 #ifdef CONFIG_MMU
 extern void __init vmalloc_init(void);
+extern unsigned long vmalloc_nr_pages(void);
 #else
 static inline void vmalloc_init(void)
 {
 }
+static inline unsigned long vmalloc_nr_pages(void) { return 0; }
 #endif
 
 extern void *vmalloc(unsigned long size);
--- a/mm/vmalloc.c~mm-show-number-of-vmalloc-pages-in-proc-meminfo
+++ a/mm/vmalloc.c
@@ -406,6 +406,13 @@ static void purge_vmap_area_lazy(void);
 static BLOCKING_NOTIFIER_HEAD(vmap_notify_list);
 static unsigned long lazy_max_pages(void);
 
+static atomic_long_t nr_vmalloc_pages;
+
+unsigned long vmalloc_nr_pages(void)
+{
+	return atomic_long_read(&nr_vmalloc_pages);
+}
+
 static struct vmap_area *__find_vmap_area(unsigned long addr)
 {
 	struct rb_node *n = vmap_area_root.rb_node;
@@ -2237,6 +2244,7 @@ static void __vunmap(const void *addr, i
 			BUG_ON(!page);
 			__free_pages(page, 0);
 		}
+		atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
 
 		kvfree(area->pages);
 	}
@@ -2414,12 +2422,14 @@ static void *__vmalloc_area_node(struct
 		if (unlikely(!page)) {
 			/* Successfully allocated i pages, free them in __vunmap() */
 			area->nr_pages = i;
+			atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
 			goto fail;
 		}
 		area->pages[i] = page;
 		if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
 			cond_resched();
 	}
+	atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
 
 	if (map_vm_area(area, prot, pages))
 		goto fail;
_

Patches currently in -mm which might be from guro@xxxxxx are

mm-postpone-kmem_cache-memcg-pointer-initialization-to-memcg_link_cache.patch
mm-rename-slab-delayed-deactivation-functions-and-fields.patch
mm-generalize-postponed-non-root-kmem_cache-deactivation.patch
mm-introduce-__memcg_kmem_uncharge_memcg.patch
mm-unify-slab-and-slub-page-accounting.patch
mm-dont-check-the-dying-flag-on-kmem_cache-creation.patch
mm-synchronize-access-to-kmem_cache-dying-flag-using-a-spinlock.patch
mm-rework-non-root-kmem_cache-lifecycle-management.patch
mm-stop-setting-page-mem_cgroup-pointer-for-slab-pages.patch
mm-reparent-memcg-kmem_caches-on-cgroup-removal.patch
mm-reparent-memcg-kmem_caches-on-cgroup-removal-fix.patch
mm-show-number-of-vmalloc-pages-in-proc-meminfo.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux