diff options
author | Dipankar Sarma <dipankar@in.ibm.com> | 2006-03-08 00:55:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-08 17:14:01 -0500 |
commit | 529bf6be5c04f2e869d07bfdb122e9fd98ade714 (patch) | |
tree | 38514bb3941c4ac2a79266e4483663b79efa2f22 /kernel | |
parent | 21a1ea9eb40411d4ee29448c53b9e4c0654d6ceb (diff) |
[PATCH] fix file counting
I have benchmarked this on an x86_64 NUMA system and see no significant
performance difference on kernbench. Tested on both x86_64 and powerpc.
The way we do file struct accounting is not very suitable for batched
freeing. For scalability reasons, file accounting was
constructor/destructor based. This meant that nr_files was decremented
only when the object was removed from the slab cache. This is susceptible
to slab fragmentation. With RCU based file structure, consequent batched
freeing and a test program like Serge's, we just speed this up and end up
with a very fragmented slab -
llm22:~ # cat /proc/sys/fs/file-nr
587730 0 758844
At the same time, I see only a 2000+ objects in filp cache. The following
patch I fixes this problem.
This patch changes the file counting by removing the filp_count_lock.
Instead we use a separate percpu counter, nr_files, for now and all
accesses to it are through get_nr_files() api. In the sysctl handler for
nr_files, we populate files_stat.nr_files before returning to user.
Counting files as an when they are created and destroyed (as opposed to
inside slab) allows us to correctly count open files with RCU.
Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sysctl.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index de2d9109194e..32b48e8ee36e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -50,6 +50,9 @@ | |||
50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
51 | #include <asm/processor.h> | 51 | #include <asm/processor.h> |
52 | 52 | ||
53 | extern int proc_nr_files(ctl_table *table, int write, struct file *filp, | ||
54 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
55 | |||
53 | #if defined(CONFIG_SYSCTL) | 56 | #if defined(CONFIG_SYSCTL) |
54 | 57 | ||
55 | /* External variables not in a header file. */ | 58 | /* External variables not in a header file. */ |
@@ -943,7 +946,7 @@ static ctl_table fs_table[] = { | |||
943 | .data = &files_stat, | 946 | .data = &files_stat, |
944 | .maxlen = 3*sizeof(int), | 947 | .maxlen = 3*sizeof(int), |
945 | .mode = 0444, | 948 | .mode = 0444, |
946 | .proc_handler = &proc_dointvec, | 949 | .proc_handler = &proc_nr_files, |
947 | }, | 950 | }, |
948 | { | 951 | { |
949 | .ctl_name = FS_MAXFILE, | 952 | .ctl_name = FS_MAXFILE, |