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

Eric Dumazet
2010-04-07T16:29:27Z

Le mercredi 07 avril 2010 =C3=A0 17:19 +0100, David Howells a =C3=A9cri=
t :

> Why not:
>=20
> ASSERT(atomic_read(&sk->sk_wmem_alloc) =3D=3D 0);
> filter =3D rcu_dereference(sk->sk_filter);
>=20
> This is much clearer, and you're not combining an unrelated assertion=
with the
> RCU dereference.

1) Because we want the check being done only when CONFIG_PROVE_RCU is
set.

2) Because rcu_dereference() default condition is : 'Am I owning
rcu_read_lock() or equivalent'.=20
In this context, I am _not_ owning rcu lock, so we will trigger a
warning.

So this is best done as is :)

I personally find this very clear and clean, this is why I acked Paul
patch :)

If we were 100% sure testing sk_wmem_alloc is not necessary, we would
have put :

filter =3D rcu_dereference_check(sk->sk_filter, 1);