mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
proc: decouple proc from VFS with "struct proc_ops"
Currently core /proc code uses "struct file_operations" for custom hooks, however, VFS doesn't directly call them. Every time VFS expands file_operations hook set, /proc code bloats for no reason. Introduce "struct proc_ops" which contains only those hooks which /proc allows to call into (open, release, read, write, ioctl, mmap, poll). It doesn't contain module pointer as well. Save ~184 bytes per usage: add/remove: 26/26 grow/shrink: 1/4 up/down: 1922/-6674 (-4752) Function old new delta sysvipc_proc_ops - 72 +72 ... config_gz_proc_ops - 72 +72 proc_get_inode 289 339 +50 proc_reg_get_unmapped_area 110 107 -3 close_pdeo 227 224 -3 proc_reg_open 289 284 -5 proc_create_data 60 53 -7 rt_cpu_seq_fops 256 - -256 ... default_affinity_proc_fops 256 - -256 Total: Before=5430095, After=5425343, chg -0.09% Link: http://lkml.kernel.org/r/20191225172228.GA13378@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0d6e24d430
commit
d56c0d45f0
7 changed files with 98 additions and 80 deletions
|
@ -90,12 +90,12 @@ static int seq_release_net(struct inode *ino, struct file *f)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations proc_net_seq_fops = {
|
||||
.open = seq_open_net,
|
||||
.read = seq_read,
|
||||
.write = proc_simple_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release_net,
|
||||
static const struct proc_ops proc_net_seq_ops = {
|
||||
.proc_open = seq_open_net,
|
||||
.proc_read = seq_read,
|
||||
.proc_write = proc_simple_write,
|
||||
.proc_lseek = seq_lseek,
|
||||
.proc_release = seq_release_net,
|
||||
};
|
||||
|
||||
struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
|
||||
|
@ -108,7 +108,7 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
|
|||
if (!p)
|
||||
return NULL;
|
||||
pde_force_lookup(p);
|
||||
p->proc_fops = &proc_net_seq_fops;
|
||||
p->proc_ops = &proc_net_seq_ops;
|
||||
p->seq_ops = ops;
|
||||
p->state_size = state_size;
|
||||
return proc_register(parent, p);
|
||||
|
@ -152,7 +152,7 @@ struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode
|
|||
if (!p)
|
||||
return NULL;
|
||||
pde_force_lookup(p);
|
||||
p->proc_fops = &proc_net_seq_fops;
|
||||
p->proc_ops = &proc_net_seq_ops;
|
||||
p->seq_ops = ops;
|
||||
p->state_size = state_size;
|
||||
p->write = write;
|
||||
|
@ -183,12 +183,12 @@ static int single_release_net(struct inode *ino, struct file *f)
|
|||
return single_release(ino, f);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_net_single_fops = {
|
||||
.open = single_open_net,
|
||||
.read = seq_read,
|
||||
.write = proc_simple_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release_net,
|
||||
static const struct proc_ops proc_net_single_ops = {
|
||||
.proc_open = single_open_net,
|
||||
.proc_read = seq_read,
|
||||
.proc_write = proc_simple_write,
|
||||
.proc_lseek = seq_lseek,
|
||||
.proc_release = single_release_net,
|
||||
};
|
||||
|
||||
struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
|
||||
|
@ -201,7 +201,7 @@ struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
|
|||
if (!p)
|
||||
return NULL;
|
||||
pde_force_lookup(p);
|
||||
p->proc_fops = &proc_net_single_fops;
|
||||
p->proc_ops = &proc_net_single_ops;
|
||||
p->single_show = show;
|
||||
return proc_register(parent, p);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mo
|
|||
if (!p)
|
||||
return NULL;
|
||||
pde_force_lookup(p);
|
||||
p->proc_fops = &proc_net_single_fops;
|
||||
p->proc_ops = &proc_net_single_ops;
|
||||
p->single_show = show;
|
||||
p->write = write;
|
||||
return proc_register(parent, p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue