diff options
author | Christoph Lameter <clameter@sgi.com> | 2008-04-28 05:12:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 11:58:21 -0400 |
commit | a10aa579878fc6f9cd17455067380bbdf1d53c91 (patch) | |
tree | c42fbb1e9422e5334c2207cafed4a2b5b1ad16c4 /mm | |
parent | b45445684198a946b587732265692e6495993abf (diff) |
vmalloc: show vmalloced areas via /proc/vmallocinfo
Implement a new proc file that allows the display of the currently allocated
vmalloc memory.
It allows to see the users of vmalloc. That is important if vmalloc space is
scarce (i386 for example).
And it's going to be important for the compound page fallback to vmalloc.
Many of the current users can be switched to use compound pages with fallback.
This means that the number of users of vmalloc is reduced and page tables no
longer necessary to access the memory. /proc/vmallocinfo allows to review how
that reduction occurs.
If memory becomes fragmented and larger order allocations are no longer
possible then /proc/vmallocinfo allows to see which compound page allocations
fell back to virtual compound pages. That is important for new users of
virtual compound pages. Such as order 1 stack allocation etc that may
fallback to virtual compound pages in the future.
/proc/vmallocinfo permissions are made readable-only-by-root to avoid possible
information leakage.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: CONFIG_MMU=n build fix]
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/vmalloc.c | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ecf91f8034bf..afa550f66537 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | 17 | #include <linux/seq_file.h> | |
18 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | 19 | ||
20 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
@@ -873,3 +873,77 @@ void free_vm_area(struct vm_struct *area) | |||
873 | kfree(area); | 873 | kfree(area); |
874 | } | 874 | } |
875 | EXPORT_SYMBOL_GPL(free_vm_area); | 875 | EXPORT_SYMBOL_GPL(free_vm_area); |
876 | |||
877 | |||
878 | #ifdef CONFIG_PROC_FS | ||
879 | static void *s_start(struct seq_file *m, loff_t *pos) | ||
880 | { | ||
881 | loff_t n = *pos; | ||
882 | struct vm_struct *v; | ||
883 | |||
884 | read_lock(&vmlist_lock); | ||
885 | v = vmlist; | ||
886 | while (n > 0 && v) { | ||
887 | n--; | ||
888 | v = v->next; | ||
889 | } | ||
890 | if (!n) | ||
891 | return v; | ||
892 | |||
893 | return NULL; | ||
894 | |||
895 | } | ||
896 | |||
897 | static void *s_next(struct seq_file *m, void *p, loff_t *pos) | ||
898 | { | ||
899 | struct vm_struct *v = p; | ||
900 | |||
901 | ++*pos; | ||
902 | return v->next; | ||
903 | } | ||
904 | |||
905 | static void s_stop(struct seq_file *m, void *p) | ||
906 | { | ||
907 | read_unlock(&vmlist_lock); | ||
908 | } | ||
909 | |||
910 | static int s_show(struct seq_file *m, void *p) | ||
911 | { | ||
912 | struct vm_struct *v = p; | ||
913 | |||
914 | seq_printf(m, "0x%p-0x%p %7ld", | ||
915 | v->addr, v->addr + v->size, v->size); | ||
916 | |||
917 | if (v->nr_pages) | ||
918 | seq_printf(m, " pages=%d", v->nr_pages); | ||
919 | |||
920 | if (v->phys_addr) | ||
921 | seq_printf(m, " phys=%lx", v->phys_addr); | ||
922 | |||
923 | if (v->flags & VM_IOREMAP) | ||
924 | seq_printf(m, " ioremap"); | ||
925 | |||
926 | if (v->flags & VM_ALLOC) | ||
927 | seq_printf(m, " vmalloc"); | ||
928 | |||
929 | if (v->flags & VM_MAP) | ||
930 | seq_printf(m, " vmap"); | ||
931 | |||
932 | if (v->flags & VM_USERMAP) | ||
933 | seq_printf(m, " user"); | ||
934 | |||
935 | if (v->flags & VM_VPAGES) | ||
936 | seq_printf(m, " vpages"); | ||
937 | |||
938 | seq_putc(m, '\n'); | ||
939 | return 0; | ||
940 | } | ||
941 | |||
942 | const struct seq_operations vmalloc_op = { | ||
943 | .start = s_start, | ||
944 | .next = s_next, | ||
945 | .stop = s_stop, | ||
946 | .show = s_show, | ||
947 | }; | ||
948 | #endif | ||
949 | |||