Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+35 -31
-30
fs/proc/proc_misc.c
··· 144 144 .llseek = seq_lseek, 145 145 .release = seq_release, 146 146 }; 147 - 148 - #ifdef CONFIG_DEBUG_SLAB_LEAK 149 - extern const struct seq_operations slabstats_op; 150 - static 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 - 167 - static 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 147 #endif 175 148 176 149 #ifdef CONFIG_MMU ··· 311 338 /* And now for trickier ones */ 312 339 #ifdef CONFIG_SLABINFO 313 340 proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); 314 - #ifdef CONFIG_DEBUG_SLAB_LEAK 315 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); 316 - #endif 317 341 #endif 318 342 #ifdef CONFIG_MMU 319 343 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
+35 -1
mm/slab.c
··· 95 95 #include <linux/init.h> 96 96 #include <linux/compiler.h> 97 97 #include <linux/cpuset.h> 98 + #include <linux/proc_fs.h> 98 99 #include <linux/seq_file.h> 99 100 #include <linux/notifier.h> 100 101 #include <linux/kallsyms.h> ··· 4444 4443 return 0; 4445 4444 } 4446 4445 4447 - const struct seq_operations slabstats_op = { 4446 + static const struct seq_operations slabstats_op = { 4448 4447 .start = leaks_start, 4449 4448 .next = s_next, 4450 4449 .stop = s_stop, 4451 4450 .show = leaks_show, 4452 4451 }; 4452 + 4453 + static int slabstats_open(struct inode *inode, struct file *file) 4454 + { 4455 + unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); 4456 + int ret = -ENOMEM; 4457 + if (n) { 4458 + ret = seq_open(file, &slabstats_op); 4459 + if (!ret) { 4460 + struct seq_file *m = file->private_data; 4461 + *n = PAGE_SIZE / (2 * sizeof(unsigned long)); 4462 + m->private = n; 4463 + n = NULL; 4464 + } 4465 + kfree(n); 4466 + } 4467 + return ret; 4468 + } 4469 + 4470 + static const struct file_operations proc_slabstats_operations = { 4471 + .open = slabstats_open, 4472 + .read = seq_read, 4473 + .llseek = seq_lseek, 4474 + .release = seq_release_private, 4475 + }; 4453 4476 #endif 4477 + 4478 + static int __init slab_proc_init(void) 4479 + { 4480 + #ifdef CONFIG_DEBUG_SLAB_LEAK 4481 + proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); 4482 + #endif 4483 + return 0; 4484 + } 4485 + module_init(slab_proc_init); 4454 4486 #endif 4455 4487 4456 4488 /**