diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-10-05 16:59:10 -0400 |
---|---|---|
committer | Alexey Dobriyan <adobriyan@gmail.com> | 2008-10-23 07:17:27 -0400 |
commit | a0ec95a8e69792e4ad642daac037c9b01ea3e2cd (patch) | |
tree | ec8f483871151c152c198b605ab7ebd6046271b8 /mm | |
parent | d6917e19f3fda8e1f88bc23ddceed952927bd716 (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')
-rw-r--r-- | mm/slab.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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 | ||
4446 | const struct seq_operations slabstats_op = { | 4447 | static 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 | |||
4454 | static 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 | |||
4471 | static 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 | |||
4479 | static 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 | } | ||
4486 | module_init(slab_proc_init); | ||
4453 | #endif | 4487 | #endif |
4454 | 4488 | ||
4455 | /** | 4489 | /** |