aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-10-05 16:59:10 -0400
committerAlexey Dobriyan <adobriyan@gmail.com>2008-10-23 07:17:27 -0400
commita0ec95a8e69792e4ad642daac037c9b01ea3e2cd (patch)
treeec8f483871151c152c198b605ab7ebd6046271b8 /mm/slab.c
parentd6917e19f3fda8e1f88bc23ddceed952927bd716 (diff)
proc: move /proc/slab_allocators boilerplate to mm/slab.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c36
1 files changed, 35 insertions, 1 deletions
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/**