Commit b1a07165 authored by Paul E. McKenney's avatar Paul E. McKenney Committed by Greg Kroah-Hartman
Browse files

rcu: Create an unrcu_pointer() to remove __rcu from a pointer



[ Upstream commit 76c8eaaf ]

The xchg() and cmpxchg() functions are sometimes used to carry out RCU
updates.  Unfortunately, this can result in sparse warnings for both
the old-value and new-value arguments, as well as for the return value.
The arguments can be dealt with using RCU_INITIALIZER():

	old_p = xchg(&p, RCU_INITIALIZER(new_p));

But a sparse warning still remains due to assigning the __rcu pointer
returned from xchg to the (most likely) non-__rcu pointer old_p.

This commit therefore provides an unrcu_pointer() macro that strips
the __rcu.  This macro can be used as follows:

	old_p = unrcu_pointer(xchg(&p, RCU_INITIALIZER(new_p)));

Reported-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Stable-dep-of: 5f35a624 ("drm/nouveau/fence:: fix warning directly dereferencing a rcu pointer")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1d1d5b90
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment