Re: [PATCH 1/2] rcu: add rcu_access_pointer and rcu_dereference_protect

From: David Howells
Date: Wed Apr 07 2010 - 11:40:26 EST

Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:

> This is not the version Paul posted.
> Removing checks just to shutup warnings ?

No. I don't see the point in the condition.

> All the point is to get lockdep assistance, and you throw it away.
> We want to explicit the condition, so that RCU users can explicitly
> state what protects their data.

You've missed the point.

For rcu_access_pointer(), _nothing_ protects the data, not only that, we don't
care: we're only checking the pointer.

For rcu_dereference_protect[ed](), I don't see that the check helps. You
don't need to be holding the RCU lock to call it, but you do need to hold all
the requisite locks required to exclude others modifying it. That's a
precondition for calling this function, so is there any point in testing it

For instance, consider the following pseudocode:

do_something(struct foo *p)
struct bar *b;
b = rcu_dereference_protected(
foo->bar, lockdep_is_held(&foo->lock));

is there any need for the condition? Does lockdep_is_held() have any side
effects beyond those listed in the Documentation directory or on its attached
banner comments?

Furthermore, I think the condition in rcu_dereference_check() may well be
misused. For instance, Paul suggested:

cred = rcu_dereference_check(delegation->cred,
delegation->inode == NULL);

but if 'c' is supposed to be the locks that protect the data, is this a valid

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at