Thread (1 message) 1 message, 1 author, 2008-11-29

[PATCH v2 4/5] fs: Introduce SINGLE dentries for pipes, socket, anon fd

flat view
DORMANTno replies

From: Eric Dumazet <hidden>
Date: 2008-11-29 08:44:23
Also in: linux-fsdevel, lkml

Sockets, pipes and anonymous fds have interesting properties.

Like other files, they use a dentry and an inode.

But dentries for these kind of files are not hashed into dcache,
since there is no way someone can lookup such a file in the vfs tree.
(/proc/{pid}/fd/{number} uses a different mechanism)

Still, allocating and freeing such dentries are expensive processes,
because we currently take dcache_lock inside d_alloc(), d_instantiate(),
and dput(). This lock is very contended on SMP machines.

This patch defines a new DCACHE_SINGLE flag, to mark a dentry as
a single one (for sockets, pipes, anonymous fd), and a new
d_alloc_single(const struct qstr *name, struct inode *inode)
method, called by the three subsystems.

Internally, dput() can take a fast path to dput_single() for
SINGLE dentries. No more atomic_dec_and_lock()
for such dentries.


Differences betwen an SINGLE dentry and a normal one are :

1) SINGLE dentry has the DCACHE_SINGLE flag
2) SINGLE dentry's parent is itself (DCACHE_DISCONNECTED)
This to avoid taking a reference on sb 'root' dentry, shared
by too many dentries.
3) They are not hashed into global hash table (DCACHE_UNHASHED)
4) Their d_alias list is empty

(socket8 bench result : from 25s to 19.9s)

Signed-off-by: Eric Dumazet <redacted>
---
fs/anon_inodes.c       |   16 ------------
fs/dcache.c            |   51 +++++++++++++++++++++++++++++++++++++++
fs/pipe.c              |   23 +----------------
include/linux/dcache.h |    9 ++++++
net/socket.c           |   24 +-----------------
5 files changed, 65 insertions(+), 58 deletions(-)

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help