* Is RCU not safe enough to protect dcache hlist?
[not found] <550248B0.5030403@outlook.com>
@ 2015-03-16 2:06 ` Lee
2015-03-16 6:02 ` Valdis.Kletnieks at vt.edu
0 siblings, 1 reply; 3+ messages in thread
From: Lee @ 2015-03-16 2:06 UTC (permalink / raw)
To: kernelnewbies
Hi, all:
I am studying the dcache in VFS recently . I found that hlist of dcache
is already protected by RCU in
__d_lookup.Is it necessary for the function -- d_lookup using
sequence lock to protect the hlist again?
struct dentry * d_lookup(struct dentry * parent, struct qstr * name)
{
struct dentry * dentry = NULL;
unsigned long seq;
do {
seq = read_seqbegin(&rename_lock);
dentry = __d_lookup(parent, name);
if (dentry)
break;
} while (read_seqretry(&rename_lock, seq));
return dentry;
}
Thanks
---
Rock Lee
^ permalink raw reply [flat|nested] 3+ messages in thread
* Is RCU not safe enough to protect dcache hlist?
2015-03-16 2:06 ` Is RCU not safe enough to protect dcache hlist? Lee
@ 2015-03-16 6:02 ` Valdis.Kletnieks at vt.edu
2015-03-16 12:15 ` Lee
0 siblings, 1 reply; 3+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2015-03-16 6:02 UTC (permalink / raw)
To: kernelnewbies
On Mon, 16 Mar 2015 10:06:37 +0800, Lee said:
> I am studying the dcache in VFS recently . I found that hlist of dcache
> is already protected by RCU in
> __d_lookup.Is it necessary for the function -- d_lookup using
> sequence lock to protect the hlist again?
RCU is useful when you can tolerate a bit of latency in other users
finding out about updated values and/or slightly stale values. That's
not an option for d_lookup(), which has to check the most recent value
in order to avoid race conditions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150316/076571ec/attachment.bin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Is RCU not safe enough to protect dcache hlist?
2015-03-16 6:02 ` Valdis.Kletnieks at vt.edu
@ 2015-03-16 12:15 ` Lee
0 siblings, 0 replies; 3+ messages in thread
From: Lee @ 2015-03-16 12:15 UTC (permalink / raw)
To: kernelnewbies
On 2015/3/16 14:02, Valdis.Kletnieks at vt.edu wrote:
> On Mon, 16 Mar 2015 10:06:37 +0800, Lee said:
>
>> I am studying the dcache in VFS recently . I found that hlist of dcache
>> is already protected by RCU in
>> __d_lookup.Is it necessary for the function -- d_lookup using
>> sequence lock to protect the hlist again?
>
> RCU is useful when you can tolerate a bit of latency in other users
> finding out about updated values and/or slightly stale values. That's
> not an option for d_lookup(), which has to check the most recent value
> in order to avoid race conditions.
>
In __d_lookup(), one hlist is protected well with RCU. But this is not
enough for the dentry_hashtable, so d_lookup() uses some mechanism to
protect the dentry_hashtable, in this condition, the mechanism is
sequence lock :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-16 12:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <550248B0.5030403@outlook.com>
2015-03-16 2:06 ` Is RCU not safe enough to protect dcache hlist? Lee
2015-03-16 6:02 ` Valdis.Kletnieks at vt.edu
2015-03-16 12:15 ` Lee
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.