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

proc: move /proc/slabinfo boilerplate to mm/slub.c, mm/slab.c

Lose dummy ->write hook in case of SLUB, it's possible now.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

+35 -32
-17
fs/proc/proc_misc.c
··· 132 132 }; 133 133 #endif 134 134 135 - #ifdef CONFIG_SLABINFO 136 - static int slabinfo_open(struct inode *inode, struct file *file) 137 - { 138 - return seq_open(file, &slabinfo_op); 139 - } 140 - static const struct file_operations proc_slabinfo_operations = { 141 - .open = slabinfo_open, 142 - .read = seq_read, 143 - .write = slabinfo_write, 144 - .llseek = seq_lseek, 145 - .release = seq_release, 146 - }; 147 - #endif 148 - 149 135 #ifdef CONFIG_MMU 150 136 static int vmalloc_open(struct inode *inode, struct file *file) 151 137 { ··· 295 309 proc_symlink("mounts", NULL, "self/mounts"); 296 310 297 311 /* And now for trickier ones */ 298 - #ifdef CONFIG_SLABINFO 299 - proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); 300 - #endif 301 312 #ifdef CONFIG_MMU 302 313 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); 303 314 #endif
-5
include/linux/slab.h
··· 288 288 return kmalloc_node(size, flags | __GFP_ZERO, node); 289 289 } 290 290 291 - #ifdef CONFIG_SLABINFO 292 - extern const struct seq_operations slabinfo_op; 293 - ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *); 294 - #endif 295 - 296 291 #endif /* _LINUX_SLAB_H */
+15 -1
mm/slab.c
··· 4259 4259 * + further values on SMP and with statistics enabled 4260 4260 */ 4261 4261 4262 - const struct seq_operations slabinfo_op = { 4262 + static const struct seq_operations slabinfo_op = { 4263 4263 .start = s_start, 4264 4264 .next = s_next, 4265 4265 .stop = s_stop, ··· 4315 4315 res = count; 4316 4316 return res; 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 + }; 4318 4331 4319 4332 #ifdef CONFIG_DEBUG_SLAB_LEAK 4320 4333 ··· 4491 4478 4492 4479 static int __init slab_proc_init(void) 4493 4480 { 4481 + proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); 4494 4482 #ifdef CONFIG_DEBUG_SLAB_LEAK 4495 4483 proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); 4496 4484 #endif
+20 -9
mm/slub.c
··· 14 14 #include <linux/interrupt.h> 15 15 #include <linux/bitops.h> 16 16 #include <linux/slab.h> 17 + #include <linux/proc_fs.h> 17 18 #include <linux/seq_file.h> 18 19 #include <linux/cpu.h> 19 20 #include <linux/cpuset.h> ··· 4418 4417 * The /proc/slabinfo ABI 4419 4418 */ 4420 4419 #ifdef CONFIG_SLABINFO 4421 - 4422 - ssize_t slabinfo_write(struct file *file, const char __user *buffer, 4423 - size_t count, loff_t *ppos) 4424 - { 4425 - return -EINVAL; 4426 - } 4427 - 4428 - 4429 4420 static void print_slabinfo_header(struct seq_file *m) 4430 4421 { 4431 4422 seq_puts(m, "slabinfo - version: 2.1\n"); ··· 4485 4492 return 0; 4486 4493 } 4487 4494 4488 - const struct seq_operations slabinfo_op = { 4495 + static const struct seq_operations slabinfo_op = { 4489 4496 .start = s_start, 4490 4497 .next = s_next, 4491 4498 .stop = s_stop, 4492 4499 .show = s_show, 4493 4500 }; 4494 4501 4502 + static int slabinfo_open(struct inode *inode, struct file *file) 4503 + { 4504 + return seq_open(file, &slabinfo_op); 4505 + } 4506 + 4507 + static const struct file_operations proc_slabinfo_operations = { 4508 + .open = slabinfo_open, 4509 + .read = seq_read, 4510 + .llseek = seq_lseek, 4511 + .release = seq_release, 4512 + }; 4513 + 4514 + static int __init slab_proc_init(void) 4515 + { 4516 + proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); 4517 + return 0; 4518 + } 4519 + module_init(slab_proc_init); 4495 4520 #endif /* CONFIG_SLABINFO */