<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/file.h, branch v2.6.16.45</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v2.6.16.45</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v2.6.16.45'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2006-03-08T22:14:01Z</updated>
<entry>
<title>[PATCH] fix file counting</title>
<updated>2006-03-08T22:14:01Z</updated>
<author>
<name>Dipankar Sarma</name>
<email>dipankar@in.ibm.com</email>
</author>
<published>2006-03-08T05:55:35Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=529bf6be5c04f2e869d07bfdb122e9fd98ade714'/>
<id>urn:sha1:529bf6be5c04f2e869d07bfdb122e9fd98ade714</id>
<content type='text'>
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 &lt;dipankar@in.ibm.com&gt;
Cc: "Paul E. McKenney" &lt;paulmck@us.ibm.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] reorder struct files_struct</title>
<updated>2005-11-14T02:14:10Z</updated>
<author>
<name>Eric Dumazet</name>
<email>dada1@cosmosbay.com</email>
</author>
<published>2005-11-14T00:06:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=95e861db3eaba7bc99f8605db70103ec3d078203'/>
<id>urn:sha1:95e861db3eaba7bc99f8605db70103ec3d078203</id>
<content type='text'>
The file_lock spinlock sits close to mostly read fields of 'struct
files_struct'

In SMP (and NUMA) environments, each time a thread wants to open or close
a file, it has to acquire the spinlock, thus invalidating the cache line
containing this spinlock on other CPUS.  So other threads doing
read()/write()/...  calls that use RCU to access the file table are going
to ask further memory (possibly NUMA) transactions to read again this
memory line.

Move the spinlock to another cache line, so that concurrent threads can
share the cache line containing 'count' and 'fdt' fields.

It's worth up to 9% on a microbenchmark using a 4-thread 2-package x86
machine.  See
http://marc.theaimsgroup.com/?l=linux-kernel&amp;m=112680448713342&amp;w=2

Signed-off-by: Eric Dumazet &lt;dada1@cosmosbay.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] mm: rename kmem_cache_s to kmem_cache</title>
<updated>2005-11-07T15:53:24Z</updated>
<author>
<name>Pekka J Enberg</name>
<email>penberg@cs.Helsinki.FI</email>
</author>
<published>2005-11-07T08:58:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2109a2d1b175dfcffbfdac693bdbe4c4ab62f11f'/>
<id>urn:sha1:2109a2d1b175dfcffbfdac693bdbe4c4ab62f11f</id>
<content type='text'>
This patch renames struct kmem_cache_s to kmem_cache so we can start using
it instead of kmem_cache_t typedef.

Signed-off-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] files: files struct with RCU</title>
<updated>2005-09-09T20:57:55Z</updated>
<author>
<name>Dipankar Sarma</name>
<email>dipankar@in.ibm.com</email>
</author>
<published>2005-09-09T20:04:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ab2af1f5005069321c5d130f09cce577b03f43ef'/>
<id>urn:sha1:ab2af1f5005069321c5d130f09cce577b03f43ef</id>
<content type='text'>
Patch to eliminate struct files_struct.file_lock spinlock on the reader side
and use rcu refcounting rcuref_xxx api for the f_count refcounter.  The
updates to the fdtable are done by allocating a new fdtable structure and
setting files-&gt;fdt to point to the new structure.  The fdtable structure is
protected by RCU thereby allowing lock-free lookup.  For fd arrays/sets that
are vmalloced, we use keventd to free them since RCU callbacks can't sleep.  A
global list of fdtable to be freed is not scalable, so we use a per-cpu list.
If keventd is already handling the current cpu's work, we use a timer to defer
queueing of that work.

Since the last publication, this patch has been re-written to avoid using
explicit memory barriers and use rcu_assign_pointer(), rcu_dereference()
premitives instead.  This required that the fd information is kept in a
separate structure (fdtable) and updated atomically.

Signed-off-by: Dipankar Sarma &lt;dipankar@in.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] files: break up files struct</title>
<updated>2005-09-09T20:57:55Z</updated>
<author>
<name>Dipankar Sarma</name>
<email>dipankar@in.ibm.com</email>
</author>
<published>2005-09-09T20:04:10Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=badf16621c1f9d1ac753be056fce11b43d6e0be5'/>
<id>urn:sha1:badf16621c1f9d1ac753be056fce11b43d6e0be5</id>
<content type='text'>
In order for the RCU to work, the file table array, sets and their sizes must
be updated atomically.  Instead of ensuring this through too many memory
barriers, we put the arrays and their sizes in a separate structure.  This
patch takes the first step of putting the file table elements in a separate
structure fdtable that is embedded withing files_struct.  It also changes all
the users to refer to the file table using files_fdtable() macro.  Subsequent
applciation of RCU becomes easier after this.

Signed-off-by: Dipankar Sarma &lt;dipankar@in.ibm.com&gt;
Signed-Off-By: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] file_table:expand_files() code cleanup</title>
<updated>2005-01-21T00:03:48Z</updated>
<author>
<name>Prasanna Meda</name>
<email>pmeda@akamai.com</email>
</author>
<published>2005-01-21T00:03:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=46c4ad2c4f871ae58af4aa9862ee53be478dcc22'/>
<id>urn:sha1:46c4ad2c4f871ae58af4aa9862ee53be478dcc22</id>
<content type='text'>
expand_files() cleanup: Make expand_files() common code for
fork.c:fork/copy_files(), open.c:open/get_unused_fd() and
fcntl.c:dup/locate_fd().

expand_files() does both expand_fd_array and expand_fd_set based on the
need.  This is used in dup().  open() and fork() duplicates the work of
expand files.  At all places we check for expanding fd array, we also check
for expanding fdset.  There is no need of checking and calling them
seperately.

This change also moves the expand_files to file.c from fcntl.c, and makes
the expand_fd_array and expand_fd_set local to that file.

Signed-off-by: Prasanna Meda &lt;pmeda@akamai.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] get_files_struct cleanup</title>
<updated>2004-04-13T02:22:25Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@osdl.org</email>
</author>
<published>2004-04-13T02:22:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a16129b8509728ae92ce205114ab453509e200f0'/>
<id>urn:sha1:a16129b8509728ae92ce205114ab453509e200f0</id>
<content type='text'>
From: Russell King &lt;rmk@arm.linux.org.uk&gt;

Cleanup the 4 duplicate "get_files_struct" implementations into one
get_files_struct() function to compliment put_files_struct().
</content>
</entry>
<entry>
<title>[PATCH] reduced overheads in fget/fput</title>
<updated>2003-05-07T15:19:50Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@digeo.com</email>
</author>
<published>2003-05-07T15:19:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6a414e64bd6ffda2cbfe3505fcd67a66cf374cc9'/>
<id>urn:sha1:6a414e64bd6ffda2cbfe3505fcd67a66cf374cc9</id>
<content type='text'>
From: Dipankar Sarma &lt;dipankar@in.ibm.com&gt;


fget() shows up on profiles, especially on SMP.  Dipankar's patch
special-cases the situation wherein there are no sharers of current-&gt;files.

In this situation we know that no other process can close this file, so it
is not necessary to increment the file's refcount.

It's ugly as sin, but makes a substantial difference.

The test is

	dd if=/dev/zero of=foo bs=1 count=1M

On 4CPU P3 xeon with 1MB L2 cache and 512MB ram:

	kernel           sys time     std-dev
	------------     --------     -------

	UP - vanilla     2.104        0.028
	UP - file        1.867        0.019

	SMP - vanilla    2.976        0.023
	SMP - file       2.719        0.026
</content>
</entry>
<entry>
<title>[PATCH] convert file_lock to a spinlock</title>
<updated>2003-04-12T19:56:37Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@digeo.com</email>
</author>
<published>2003-04-12T19:56:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a413a276a079b9a8f125f921e055b908b95f8251'/>
<id>urn:sha1:a413a276a079b9a8f125f921e055b908b95f8251</id>
<content type='text'>
Time to write a 2M file, one byte at a time:

Before:
        1.09s user 4.92s system 99% cpu 6.014 total
        0.74s user 5.28s system 99% cpu 6.023 total
        1.03s user 4.97s system 100% cpu 5.991 total

After:
	0.79s user 5.17s system 99% cpu 5.993 total
	0.79s user 5.17s system 100% cpu 5.957 total
	0.84s user 5.11s system 100% cpu 5.942 total
</content>
</entry>
<entry>
<title>[PATCH] file_list_lock contention fixes</title>
<updated>2003-03-18T05:15:03Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@digeo.com</email>
</author>
<published>2003-03-18T05:15:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cc6c76b93381fd8ba46ddd162a812c10a51b4352'/>
<id>urn:sha1:cc6c76b93381fd8ba46ddd162a812c10a51b4352</id>
<content type='text'>
Patch from Manfred Spraul &lt;manfred@colorfullife.com&gt;

Fixes the lock contention over file_list_lock by simply removing the unneeded
anon_list.  So filp allocation does not need to take a global lock any more.

The use of a spinlock to protect files_stat.nr_files is a bit awkward, but
the alternative is a custom sysctl handler, and isn't much more efficient
anyway.
</content>
</entry>
</feed>
