summaryrefslogtreecommitdiff
path: root/include/linux/compiler-context-analysis.h
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2026-01-19 12:05:52 +0300
committerPeter Zijlstra <peterz@infradead.org>2026-01-28 22:45:24 +0300
commitd084a73714f818ce509022e1aa9483cabf797c16 (patch)
treea6267c99ccbf07913d353a9ab91d09f4161c6619 /include/linux/compiler-context-analysis.h
parent3b9ed30344a866f6f96896b3ce64303b9074682b (diff)
downloadlinux-d084a73714f818ce509022e1aa9483cabf797c16.tar.xz
compiler-context-analysis: Introduce scoped init guards
Add scoped init guard definitions for common synchronization primitives supported by context analysis. The scoped init guards treat the context as active within initialization scope of the underlying context lock, given initialization implies exclusive access to the underlying object. This allows initialization of guarded members without disabling context analysis, while documenting initialization from subsequent usage. The documentation is updated with the new recommendation. Where scoped init guards are not provided or cannot be implemented (ww_mutex omitted for lack of multi-arg guard initializers), the alternative is to just disable context analysis where guarded members are initialized. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/all/20251212095943.GM3911114@noisy.programming.kicks-ass.net/ Link: https://patch.msgid.link/20260119094029.1344361-3-elver@google.com
Diffstat (limited to 'include/linux/compiler-context-analysis.h')
-rw-r--r--include/linux/compiler-context-analysis.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/include/linux/compiler-context-analysis.h b/include/linux/compiler-context-analysis.h
index e86b8a3c2f89..00c074a2ccb0 100644
--- a/include/linux/compiler-context-analysis.h
+++ b/include/linux/compiler-context-analysis.h
@@ -32,13 +32,8 @@
/*
* The "assert_capability" attribute is a bit confusingly named. It does not
* generate a check. Instead, it tells the analysis to *assume* the capability
- * is held. This is used for:
- *
- * 1. Augmenting runtime assertions, that can then help with patterns beyond the
- * compiler's static reasoning abilities.
- *
- * 2. Initialization of context locks, so we can access guarded variables right
- * after initialization (nothing else should access the same object yet).
+ * is held. This is used for augmenting runtime assertions, that can then help
+ * with patterns beyond the compiler's static reasoning abilities.
*/
# define __assumes_ctx_lock(...) __attribute__((assert_capability(__VA_ARGS__)))
# define __assumes_shared_ctx_lock(...) __attribute__((assert_shared_capability(__VA_ARGS__)))