Commit b3423415fbc2e5461605826317da1c8dbbf21f97
Committed by
Linus Torvalds
1 parent
d18de5a272
Exists in
master
and in
7 other branches
[PATCH] dcache: avoid RCU for never-hashed dentries
Some dentries don't need to be globally visible in dentry hashtable. (pipes & sockets) Such dentries dont need to wait for a RCU grace period at delete time. Being able to free them permits a better CPU cache use (hot cache) This patch combined with (dont insert pipe dentries into dentry_hashtable) reduced time of { pipe(p); close(p[0]); close(p[1]);} on my UP machine (1.6 GHz Pentium-M) from 3.23 us to 2.86 us (But this patch does not depend on other patches, only bench results) Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Maneesh Soni <maneesh@in.ibm.com> Cc: "Paul E. McKenney" <paulmck@us.ibm.com> Cc: Dipankar Sarma <dipankar@in.ibm.com> Acked-by: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 12 additions and 4 deletions Side-by-side Diff
fs/dcache.c
... | ... | @@ -68,15 +68,19 @@ |
68 | 68 | .age_limit = 45, |
69 | 69 | }; |
70 | 70 | |
71 | -static void d_callback(struct rcu_head *head) | |
71 | +static void __d_free(struct dentry *dentry) | |
72 | 72 | { |
73 | - struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu); | |
74 | - | |
75 | 73 | if (dname_external(dentry)) |
76 | 74 | kfree(dentry->d_name.name); |
77 | 75 | kmem_cache_free(dentry_cache, dentry); |
78 | 76 | } |
79 | 77 | |
78 | +static void d_callback(struct rcu_head *head) | |
79 | +{ | |
80 | + struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu); | |
81 | + __d_free(dentry); | |
82 | +} | |
83 | + | |
80 | 84 | /* |
81 | 85 | * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry |
82 | 86 | * inside dcache_lock. |
... | ... | @@ -85,7 +89,11 @@ |
85 | 89 | { |
86 | 90 | if (dentry->d_op && dentry->d_op->d_release) |
87 | 91 | dentry->d_op->d_release(dentry); |
88 | - call_rcu(&dentry->d_u.d_rcu, d_callback); | |
92 | + /* if dentry was never inserted into hash, immediate free is OK */ | |
93 | + if (dentry->d_hash.pprev == NULL) | |
94 | + __d_free(dentry); | |
95 | + else | |
96 | + call_rcu(&dentry->d_u.d_rcu, d_callback); | |
89 | 97 | } |
90 | 98 | |
91 | 99 | /* |