summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/meminfo.c2
-rw-r--r--include/linux/vmalloc.h2
-rw-r--r--mm/vmalloc.c10
3 files changed, 13 insertions, 1 deletions
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 568d90e17c17..465ea0153b2a 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -120,7 +120,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
120 show_val_kb(m, "Committed_AS: ", committed); 120 show_val_kb(m, "Committed_AS: ", committed);
121 seq_printf(m, "VmallocTotal: %8lu kB\n", 121 seq_printf(m, "VmallocTotal: %8lu kB\n",
122 (unsigned long)VMALLOC_TOTAL >> 10); 122 (unsigned long)VMALLOC_TOTAL >> 10);
123 show_val_kb(m, "VmallocUsed: ", 0ul); 123 show_val_kb(m, "VmallocUsed: ", vmalloc_nr_pages());
124 show_val_kb(m, "VmallocChunk: ", 0ul); 124 show_val_kb(m, "VmallocChunk: ", 0ul);
125 show_val_kb(m, "Percpu: ", pcpu_nr_pages()); 125 show_val_kb(m, "Percpu: ", pcpu_nr_pages());
126 126
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 51e131245379..9b21d0047710 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -72,10 +72,12 @@ extern void vm_unmap_aliases(void);
72 72
73#ifdef CONFIG_MMU 73#ifdef CONFIG_MMU
74extern void __init vmalloc_init(void); 74extern void __init vmalloc_init(void);
75extern unsigned long vmalloc_nr_pages(void);
75#else 76#else
76static inline void vmalloc_init(void) 77static inline void vmalloc_init(void)
77{ 78{
78} 79}
80static inline unsigned long vmalloc_nr_pages(void) { return 0; }
79#endif 81#endif
80 82
81extern void *vmalloc(unsigned long size); 83extern void *vmalloc(unsigned long size);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index edb212298c8a..4fa8d84599b0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -406,6 +406,13 @@ static void purge_vmap_area_lazy(void);
406static BLOCKING_NOTIFIER_HEAD(vmap_notify_list); 406static BLOCKING_NOTIFIER_HEAD(vmap_notify_list);
407static unsigned long lazy_max_pages(void); 407static unsigned long lazy_max_pages(void);
408 408
409static atomic_long_t nr_vmalloc_pages;
410
411unsigned long vmalloc_nr_pages(void)
412{
413 return atomic_long_read(&nr_vmalloc_pages);
414}
415
409static struct vmap_area *__find_vmap_area(unsigned long addr) 416static struct vmap_area *__find_vmap_area(unsigned long addr)
410{ 417{
411 struct rb_node *n = vmap_area_root.rb_node; 418 struct rb_node *n = vmap_area_root.rb_node;
@@ -2237,6 +2244,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
2237 BUG_ON(!page); 2244 BUG_ON(!page);
2238 __free_pages(page, 0); 2245 __free_pages(page, 0);
2239 } 2246 }
2247 atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
2240 2248
2241 kvfree(area->pages); 2249 kvfree(area->pages);
2242 } 2250 }
@@ -2414,12 +2422,14 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
2414 if (unlikely(!page)) { 2422 if (unlikely(!page)) {
2415 /* Successfully allocated i pages, free them in __vunmap() */ 2423 /* Successfully allocated i pages, free them in __vunmap() */
2416 area->nr_pages = i; 2424 area->nr_pages = i;
2425 atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
2417 goto fail; 2426 goto fail;
2418 } 2427 }
2419 area->pages[i] = page; 2428 area->pages[i] = page;
2420 if (gfpflags_allow_blocking(gfp_mask|highmem_mask)) 2429 if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
2421 cond_resched(); 2430 cond_resched();
2422 } 2431 }
2432 atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
2423 2433
2424 if (map_vm_area(area, prot, pages)) 2434 if (map_vm_area(area, prot, pages))
2425 goto fail; 2435 goto fail;