Skip to content

Commit

Permalink
[PATCH] sysctl: reimplement the sysctl proc support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Feb 14, 2007
1 parent 1ff007e commit 77b14db
Show file tree
Hide file tree
Showing 10 changed files with 486 additions and 199 deletions.
2 changes: 1 addition & 1 deletion fs/proc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ proc-y := nommu.o task_nommu.o
proc-$(CONFIG_MMU) := mmu.o task_mmu.o

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

proc-$(CONFIG_PROC_KCORE) += kcore.o
proc-$(CONFIG_PROC_VMCORE) += vmcore.o
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static loff_t proc_file_lseek(struct file *, loff_t, int);

DEFINE_SPINLOCK(proc_subdir_lock);

int proc_match(int len, const char *name, struct proc_dir_entry *de)
static int proc_match(int len, const char *name, struct proc_dir_entry *de)
{
if (de->namelen != len)
return 0;
Expand Down
1 change: 1 addition & 0 deletions fs/proc/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
if (!inode)
goto out_ino;

PROC_I(inode)->fd = 0;
PROC_I(inode)->pde = de;
if (de) {
if (de->mode) {
Expand Down
2 changes: 2 additions & 0 deletions fs/proc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <linux/proc_fs.h>

extern int proc_sys_init(void);

struct vmalloc_info {
unsigned long used;
unsigned long largest_chunk;
Expand Down
Loading

0 comments on commit 77b14db

Please sign in to comment.