]> git.baikalelectronics.ru Git - kernel.git/commit
rcu: Create an unrcu_pointer() to remove __rcu from a pointer
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 24 Jun 2021 16:05:51 +0000 (18:05 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 24 Jun 2021 17:41:14 +0000 (19:41 +0200)
commit1894df41ac5453c97d13059450e744be03f35642
tree98f9f383bb65b166cf62c54da71080d22aee6023
parente04d3a688480942e5a288af1cefadae68a49c1f5
rcu: Create an unrcu_pointer() to remove __rcu from a pointer

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: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210624160609.292325-2-toke@redhat.com
include/linux/rcupdate.h