Commit 5f6a6a9c4e4d790aae55cb412a7643329057c5e0

Authored by Alexey Dobriyan
1 parent 7b3c3a50a3

proc: move /proc/vmallocinfo to mm/vmalloc.c

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>

Showing 3 changed files with 32 additions and 31 deletions Side-by-side Diff

... ... @@ -132,31 +132,6 @@
132 132 };
133 133 #endif
134 134  
135   -#ifdef CONFIG_MMU
136   -static int vmalloc_open(struct inode *inode, struct file *file)
137   -{
138   - unsigned int *ptr = NULL;
139   - int ret;
140   -
141   - if (NUMA_BUILD)
142   - ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
143   - ret = seq_open(file, &vmalloc_op);
144   - if (!ret) {
145   - struct seq_file *m = file->private_data;
146   - m->private = ptr;
147   - } else
148   - kfree(ptr);
149   - return ret;
150   -}
151   -
152   -static const struct file_operations proc_vmalloc_operations = {
153   - .open = vmalloc_open,
154   - .read = seq_read,
155   - .llseek = seq_lseek,
156   - .release = seq_release_private,
157   -};
158   -#endif
159   -
160 135 #ifdef CONFIG_PROC_PAGE_MONITOR
161 136 #define KPMSIZE sizeof(u64)
162 137 #define KPMMASK (KPMSIZE - 1)
... ... @@ -295,9 +270,6 @@
295 270 proc_symlink("mounts", NULL, "self/mounts");
296 271  
297 272 /* And now for trickier ones */
298   -#ifdef CONFIG_MMU
299   - proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
300   -#endif
301 273 proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
302 274 proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
303 275 proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
include/linux/vmalloc.h
... ... @@ -103,7 +103,5 @@
103 103 extern rwlock_t vmlist_lock;
104 104 extern struct vm_struct *vmlist;
105 105  
106   -extern const struct seq_operations vmalloc_op;
107   -
108 106 #endif /* _LINUX_VMALLOC_H */
... ... @@ -15,6 +15,7 @@
15 15 #include <linux/slab.h>
16 16 #include <linux/spinlock.h>
17 17 #include <linux/interrupt.h>
  18 +#include <linux/proc_fs.h>
18 19 #include <linux/seq_file.h>
19 20 #include <linux/debugobjects.h>
20 21 #include <linux/kallsyms.h>
21 22  
... ... @@ -1718,11 +1719,41 @@
1718 1719 return 0;
1719 1720 }
1720 1721  
1721   -const struct seq_operations vmalloc_op = {
  1722 +static const struct seq_operations vmalloc_op = {
1722 1723 .start = s_start,
1723 1724 .next = s_next,
1724 1725 .stop = s_stop,
1725 1726 .show = s_show,
1726 1727 };
  1728 +
  1729 +static int vmalloc_open(struct inode *inode, struct file *file)
  1730 +{
  1731 + unsigned int *ptr = NULL;
  1732 + int ret;
  1733 +
  1734 + if (NUMA_BUILD)
  1735 + ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
  1736 + ret = seq_open(file, &vmalloc_op);
  1737 + if (!ret) {
  1738 + struct seq_file *m = file->private_data;
  1739 + m->private = ptr;
  1740 + } else
  1741 + kfree(ptr);
  1742 + return ret;
  1743 +}
  1744 +
  1745 +static const struct file_operations proc_vmalloc_operations = {
  1746 + .open = vmalloc_open,
  1747 + .read = seq_read,
  1748 + .llseek = seq_lseek,
  1749 + .release = seq_release_private,
  1750 +};
  1751 +
  1752 +static int __init proc_vmalloc_init(void)
  1753 +{
  1754 + proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
  1755 + return 0;
  1756 +}
  1757 +module_init(proc_vmalloc_init);
1727 1758 #endif