aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/proc_misc.c30
-rw-r--r--mm/slab.c36
2 files changed, 35 insertions, 31 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 9e1d2684ce93..5bca02842d07 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -144,33 +144,6 @@ static const struct file_operations proc_slabinfo_operations = {
144 .llseek = seq_lseek, 144 .llseek = seq_lseek,
145 .release = seq_release, 145 .release = seq_release,
146}; 146};
147
148#ifdef CONFIG_DEBUG_SLAB_LEAK
149extern const struct seq_operations slabstats_op;
150static int slabstats_open(struct inode *inode, struct file *file)
151{
152 unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
153 int ret = -ENOMEM;
154 if (n) {
155 ret = seq_open(file, &slabstats_op);
156 if (!ret) {
157 struct seq_file *m = file->private_data;
158 *n = PAGE_SIZE / (2 * sizeof(unsigned long));
159 m->private = n;
160 n = NULL;
161 }
162 kfree(n);
163 }
164 return ret;
165}
166
167static const struct file_operations proc_slabstats_operations = {
168 .open = slabstats_open,
169 .read = seq_read,
170 .llseek = seq_lseek,
171 .release = seq_release_private,
172};
173#endif
174#endif 147#endif
175 148
176#ifdef CONFIG_MMU 149#ifdef CONFIG_MMU
@@ -338,9 +311,6 @@ void __init proc_misc_init(void)
338 /* And now for trickier ones */ 311 /* And now for trickier ones */
339#ifdef CONFIG_SLABINFO 312#ifdef CONFIG_SLABINFO
340 proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); 313 proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
341#ifdef CONFIG_DEBUG_SLAB_LEAK
342 proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
343#endif
344#endif 314#endif
345#ifdef CONFIG_MMU 315#ifdef CONFIG_MMU
346 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); 316 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
diff --git a/mm/slab.c b/mm/slab.c
index e76eee466886..d53ac9c26ab7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -95,6 +95,7 @@
95#include <linux/init.h> 95#include <linux/init.h>
96#include <linux/compiler.h> 96#include <linux/compiler.h>
97#include <linux/cpuset.h> 97#include <linux/cpuset.h>
98#include <linux/proc_fs.h>
98#include <linux/seq_file.h> 99#include <linux/seq_file.h>
99#include <linux/notifier.h> 100#include <linux/notifier.h>
100#include <linux/kallsyms.h> 101#include <linux/kallsyms.h>
@@ -4443,13 +4444,46 @@ static int leaks_show(struct seq_file *m, void *p)
4443 return 0; 4444 return 0;
4444} 4445}
4445 4446
4446const struct seq_operations slabstats_op = { 4447static const struct seq_operations slabstats_op = {
4447 .start = leaks_start, 4448 .start = leaks_start,
4448 .next = s_next, 4449 .next = s_next,
4449 .stop = s_stop, 4450 .stop = s_stop,
4450 .show = leaks_show, 4451 .show = leaks_show,
4451}; 4452};
4453
4454static int slabstats_open(struct inode *inode, struct file *file)
4455{
4456 unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
4457 int ret = -ENOMEM;
4458 if (n) {
4459 ret = seq_open(file, &slabstats_op);
4460 if (!ret) {
4461 struct seq_file *m = file->private_data;
4462 *n = PAGE_SIZE / (2 * sizeof(unsigned long));
4463 m->private = n;
4464 n = NULL;
4465 }
4466 kfree(n);
4467 }
4468 return ret;
4469}
4470
4471static const struct file_operations proc_slabstats_operations = {
4472 .open = slabstats_open,
4473 .read = seq_read,
4474 .llseek = seq_lseek,
4475 .release = seq_release_private,
4476};
4477#endif
4478
4479static int __init slab_proc_init(void)
4480{
4481#ifdef CONFIG_DEBUG_SLAB_LEAK
4482 proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
4452#endif 4483#endif
4484 return 0;
4485}
4486module_init(slab_proc_init);
4453#endif 4487#endif
4454 4488
4455/** 4489/**