Skip to content

Commit 77b14db

Browse files
ebiedermLinus Torvalds
authored andcommitted
[PATCH] sysctl: reimplement the sysctl proc support
With this change the sysctl inodes can be cached and nothing needs to be done when removing a sysctl table. For a cost of 2K code we will save about 4K of static tables (when we remove de from ctl_table) and 70K in proc_dir_entries that we will not allocate, or about half that on a 32bit arch. The speed feels about the same, even though we can now cache the sysctl dentries :( We get the core advantage that we don't need to have a 1 to 1 mapping between ctl table entries and proc files. Making it possible to have /proc/sys vary depending on the namespace you are in. The currently merged namespaces don't have an issue here but the network namespace under /proc/sys/net needs to have different directories depending on which network adapters are visible. By simply being a cache different directories being visible depending on who you are is trivial to implement. [akpm@osdl.org: fix uninitialised var] [akpm@osdl.org: fix ARM build] [bunk@stusta.de: make things static] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1ff007e commit 77b14db

10 files changed

Lines changed: 486 additions & 199 deletions

File tree

‎fs/proc/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ proc-y := nommu.o task_nommu.o
88
proc-$(CONFIG_MMU) := mmu.o task_mmu.o
99

1010
proc-y += inode.o root.o base.o generic.o array.o \
11-
proc_tty.o proc_misc.o
11+
proc_tty.o proc_misc.o proc_sysctl.o
1212

1313
proc-$(CONFIG_PROC_KCORE) += kcore.o
1414
proc-$(CONFIG_PROC_VMCORE) += vmcore.o

‎fs/proc/generic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static loff_t proc_file_lseek(struct file *, loff_t, int);
3232

3333
DEFINE_SPINLOCK(proc_subdir_lock);
3434

35-
int proc_match(int len, const char *name, struct proc_dir_entry *de)
35+
static int proc_match(int len, const char *name, struct proc_dir_entry *de)
3636
{
3737
if (de->namelen != len)
3838
return 0;

‎fs/proc/inode.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
161161
if (!inode)
162162
goto out_ino;
163163

164+
PROC_I(inode)->fd = 0;
164165
PROC_I(inode)->pde = de;
165166
if (de) {
166167
if (de->mode) {

‎fs/proc/internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <linux/proc_fs.h>
1313

14+
extern int proc_sys_init(void);
15+
1416
struct vmalloc_info {
1517
unsigned long used;
1618
unsigned long largest_chunk;

0 commit comments

Comments
 (0)