summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2026-06-28 09:00:01 -0700
committerPaul E. McKenney <paulmck@kernel.org>2026-07-23 10:47:10 -0700
commit573d76f7db5ba050bc7c7c73d30e1364fcee269b (patch)
treed430efa7e98c14258d9ec1336686a54da1a0bae6
parent1384ea908e5de451061b50b4eb76c4440c4d4a0d (diff)
downloadlinux-next-573d76f7db5ba050bc7c7c73d30e1364fcee269b.tar.gz
linux-next-573d76f7db5ba050bc7c7c73d30e1364fcee269b.zip
rcu: Mark __rcu_access_pointer() as context_unsafe()
A simple comparison of a pointer returned by rcu_access_pointer() results in a context-analysis warning for lockless inspection of the RCU-protected (also known as __rcu-protected) pointer. This can be suppressed by placing context_unsafe() calls around calls rcu_access_pointer(), but this is messy and distracting. This commit therefore wraps the underlying __rcu_access_pointer() macro with a call to context_unsafe(), thereby informing the context-analysis code that rcu_access_pointer() may safely be invoked outside of an RCU read-side critical section. Reported-by: Christoph Hellwig <hch@lst.de> Suggested-by: Marco Elver <elver@google.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Tested-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Marco Elver <elver@google.com>
-rw-r--r--include/linux/rcupdate.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 5e95acc33989..e40dc2e20c5b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -490,12 +490,12 @@ context_unsafe( \
*/
#define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu))
-#define __rcu_access_pointer(p, local, space) \
+#define __rcu_access_pointer(p, local, space) context_unsafe( \
({ \
typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
rcu_check_sparse(p, space); \
((typeof(*p) __force __kernel *)(local)); \
-})
+}) )
#define __rcu_dereference_check(p, local, c, space) \
({ \
/* Dependency order vs. p above. */ \