diff options
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 52 |
1 files changed, 50 insertions, 2 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> |
@@ -4258,7 +4259,7 @@ static int s_show(struct seq_file *m, void *p) | |||
4258 | * + further values on SMP and with statistics enabled | 4259 | * + further values on SMP and with statistics enabled |
4259 | */ | 4260 | */ |
4260 | 4261 | ||
4261 | const struct seq_operations slabinfo_op = { | 4262 | static const struct seq_operations slabinfo_op = { |
4262 | .start = s_start, | 4263 | .start = s_start, |
4263 | .next = s_next, | 4264 | .next = s_next, |
4264 | .stop = s_stop, | 4265 | .stop = s_stop, |
@@ -4315,6 +4316,19 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer, | |||
4315 | return res; | 4316 | return res; |
4316 | } | 4317 | } |
4317 | 4318 | ||
4319 | static int slabinfo_open(struct inode *inode, struct file *file) | ||
4320 | { | ||
4321 | return seq_open(file, &slabinfo_op); | ||
4322 | } | ||
4323 | |||
4324 | static const struct file_operations proc_slabinfo_operations = { | ||
4325 | .open = slabinfo_open, | ||
4326 | .read = seq_read, | ||
4327 | .write = slabinfo_write, | ||
4328 | .llseek = seq_lseek, | ||
4329 | .release = seq_release, | ||
4330 | }; | ||
4331 | |||
4318 | #ifdef CONFIG_DEBUG_SLAB_LEAK | 4332 | #ifdef CONFIG_DEBUG_SLAB_LEAK |
4319 | 4333 | ||
4320 | static void *leaks_start(struct seq_file *m, loff_t *pos) | 4334 | static void *leaks_start(struct seq_file *m, loff_t *pos) |
@@ -4443,13 +4457,47 @@ static int leaks_show(struct seq_file *m, void *p) | |||
4443 | return 0; | 4457 | return 0; |
4444 | } | 4458 | } |
4445 | 4459 | ||
4446 | const struct seq_operations slabstats_op = { | 4460 | static const struct seq_operations slabstats_op = { |
4447 | .start = leaks_start, | 4461 | .start = leaks_start, |
4448 | .next = s_next, | 4462 | .next = s_next, |
4449 | .stop = s_stop, | 4463 | .stop = s_stop, |
4450 | .show = leaks_show, | 4464 | .show = leaks_show, |
4451 | }; | 4465 | }; |
4466 | |||
4467 | static int slabstats_open(struct inode *inode, struct file *file) | ||
4468 | { | ||
4469 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); | ||
4470 | int ret = -ENOMEM; | ||
4471 | if (n) { | ||
4472 | ret = seq_open(file, &slabstats_op); | ||
4473 | if (!ret) { | ||
4474 | struct seq_file *m = file->private_data; | ||
4475 | *n = PAGE_SIZE / (2 * sizeof(unsigned long)); | ||
4476 | m->private = n; | ||
4477 | n = NULL; | ||
4478 | } | ||
4479 | kfree(n); | ||
4480 | } | ||
4481 | return ret; | ||
4482 | } | ||
4483 | |||
4484 | static const struct file_operations proc_slabstats_operations = { | ||
4485 | .open = slabstats_open, | ||
4486 | .read = seq_read, | ||
4487 | .llseek = seq_lseek, | ||
4488 | .release = seq_release_private, | ||
4489 | }; | ||
4490 | #endif | ||
4491 | |||
4492 | static int __init slab_proc_init(void) | ||
4493 | { | ||
4494 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); | ||
4495 | #ifdef CONFIG_DEBUG_SLAB_LEAK | ||
4496 | proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); | ||
4452 | #endif | 4497 | #endif |
4498 | return 0; | ||
4499 | } | ||
4500 | module_init(slab_proc_init); | ||
4453 | #endif | 4501 | #endif |
4454 | 4502 | ||
4455 | /** | 4503 | /** |