]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm, vmalloc: move get_vmalloc_info() to vmalloc.c
authorJoonsoo Kim <js1304@gmail.com>
Wed, 20 Mar 2013 04:07:24 +0000 (15:07 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 21 Mar 2013 05:33:52 +0000 (16:33 +1100)
Now get_vmalloc_info() is in fs/proc/mmu.c.  There is no reason that this
code must be here and it's implementation needs vmlist_lock and it iterate
a vmlist which may be internal data structure for vmalloc.

It is preferable that vmlist_lock and vmlist is only used in vmalloc.c
for maintainability. So move the code to vmalloc.c

Signed-off-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/Makefile
fs/proc/internal.h
fs/proc/meminfo.c
fs/proc/mmu.c [deleted file]
include/linux/vmalloc.h
mm/vmalloc.c

index 712f24db9600f26dc919e5024255916de3a45067..ab30716584f55c0dd488c6d567962172d2a5188c 100644 (file)
@@ -5,7 +5,7 @@
 obj-y   += proc.o
 
 proc-y                 := nommu.o task_nommu.o
-proc-$(CONFIG_MMU)     := mmu.o task_mmu.o
+proc-$(CONFIG_MMU)     := task_mmu.o
 
 proc-y       += inode.o root.o base.o generic.o array.o \
                fd.o
index 85ff3a4598b348cbf30772aa69c44e082525a488..75710357a51713b78144ca256cef6a785a3cc0f1 100644 (file)
@@ -30,24 +30,6 @@ extern int proc_net_init(void);
 static inline int proc_net_init(void) { return 0; }
 #endif
 
-struct vmalloc_info {
-       unsigned long   used;
-       unsigned long   largest_chunk;
-};
-
-#ifdef CONFIG_MMU
-#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
-extern void get_vmalloc_info(struct vmalloc_info *vmi);
-#else
-
-#define VMALLOC_TOTAL 0UL
-#define get_vmalloc_info(vmi)                  \
-do {                                           \
-       (vmi)->used = 0;                        \
-       (vmi)->largest_chunk = 0;               \
-} while(0)
-#endif
-
 extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns,
                                struct pid *pid, struct task_struct *task);
 extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
index 1efaaa19c4f3ae31f47106c6e9555954ca1cb1fe..5aa847a603c0d1325c31d1b1e968a926fa170cb8 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/swap.h>
 #include <linux/vmstat.h>
 #include <linux/atomic.h>
+#include <linux/vmalloc.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include "internal.h"
diff --git a/fs/proc/mmu.c b/fs/proc/mmu.c
deleted file mode 100644 (file)
index 8ae221d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* mmu.c: mmu memory info files
- *
- * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <linux/spinlock.h>
-#include <linux/vmalloc.h>
-#include <linux/highmem.h>
-#include <asm/pgtable.h>
-#include "internal.h"
-
-void get_vmalloc_info(struct vmalloc_info *vmi)
-{
-       struct vm_struct *vma;
-       unsigned long free_area_size;
-       unsigned long prev_end;
-
-       vmi->used = 0;
-
-       if (!vmlist) {
-               vmi->largest_chunk = VMALLOC_TOTAL;
-       }
-       else {
-               vmi->largest_chunk = 0;
-
-               prev_end = VMALLOC_START;
-
-               read_lock(&vmlist_lock);
-
-               for (vma = vmlist; vma; vma = vma->next) {
-                       unsigned long addr = (unsigned long) vma->addr;
-
-                       /*
-                        * Some archs keep another range for modules in vmlist
-                        */
-                       if (addr < VMALLOC_START)
-                               continue;
-                       if (addr >= VMALLOC_END)
-                               break;
-
-                       vmi->used += vma->size;
-
-                       free_area_size = addr - prev_end;
-                       if (vmi->largest_chunk < free_area_size)
-                               vmi->largest_chunk = free_area_size;
-
-                       prev_end = vma->size + addr;
-               }
-
-               if (VMALLOC_END - prev_end > vmi->largest_chunk)
-                       vmi->largest_chunk = VMALLOC_END - prev_end;
-
-               read_unlock(&vmlist_lock);
-       }
-}
index 6071e911c7f4deff2258ea404416f133c4b6ec36..698b1e50d3a4576e2585e14f13c033cb501366ec 100644 (file)
@@ -158,4 +158,22 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
 # endif
 #endif
 
+struct vmalloc_info {
+       unsigned long   used;
+       unsigned long   largest_chunk;
+};
+
+#ifdef CONFIG_MMU
+#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
+extern void get_vmalloc_info(struct vmalloc_info *vmi);
+#else
+
+#define VMALLOC_TOTAL 0UL
+#define get_vmalloc_info(vmi)                  \
+do {                                           \
+       (vmi)->used = 0;                        \
+       (vmi)->largest_chunk = 0;               \
+} while (0)
+#endif
+
 #endif /* _LINUX_VMALLOC_H */
index 0f751f2068c3f02d7b69b5fd90f4354831172eb5..1d9878b7cf52e08bbcc0c335dc97365a9901413c 100644 (file)
@@ -2645,5 +2645,49 @@ static int __init proc_vmalloc_init(void)
        return 0;
 }
 module_init(proc_vmalloc_init);
+
+void get_vmalloc_info(struct vmalloc_info *vmi)
+{
+       struct vm_struct *vma;
+       unsigned long free_area_size;
+       unsigned long prev_end;
+
+       vmi->used = 0;
+
+       if (!vmlist) {
+               vmi->largest_chunk = VMALLOC_TOTAL;
+       } else {
+               vmi->largest_chunk = 0;
+
+               prev_end = VMALLOC_START;
+
+               read_lock(&vmlist_lock);
+
+               for (vma = vmlist; vma; vma = vma->next) {
+                       unsigned long addr = (unsigned long) vma->addr;
+
+                       /*
+                        * Some archs keep another range for modules in vmlist
+                        */
+                       if (addr < VMALLOC_START)
+                               continue;
+                       if (addr >= VMALLOC_END)
+                               break;
+
+                       vmi->used += vma->size;
+
+                       free_area_size = addr - prev_end;
+                       if (vmi->largest_chunk < free_area_size)
+                               vmi->largest_chunk = free_area_size;
+
+                       prev_end = vma->size + addr;
+               }
+
+               if (VMALLOC_END - prev_end > vmi->largest_chunk)
+                       vmi->largest_chunk = VMALLOC_END - prev_end;
+
+               read_unlock(&vmlist_lock);
+       }
+}
 #endif