Skip to contentSkip to conversation

include/linux/local_lock_internal.h: Make this header file again compatible with sparse

PATCH Applied Bart Van Assche 3 participants 3 messages Mar 11 – Mar 16 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/linux/local_lock_internal.h: Make this header file again compatible with sparse

There are two versions of the __this_cpu_local_lock() definitions in include/linux/local_lock_internal.h: one version that relies on the Clang overloading functionality and another version that does not. Select the latter version when using sparse. This patch fixes the following errors reported by sparse:

include/linux/local_lock_internal.h:331:40: sparse: sparse: multiple definitions for function '__this_cpu_local_lock' include/linux/local_lock_internal.h:325:37: sparse: the previous one is here

Fixes d3febf16dee2 ("locking/local_lock: Support Clang's context analysis")
---
 include/linux/local_lock_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/local_lock_internal.h +1 -1
index eff711bf973f..234be7f12c15 100644
@@ -315,7 +315,7 @@ do {								\
 
 #endif /* CONFIG_PREEMPT_RT */
 
-#if defined(WARN_CONTEXT_ANALYSIS)
+#if defined(WARN_CONTEXT_ANALYSIS) && !defined(__CHECKER__)
 /*
  * Because the compiler only knows about the base per-CPU variable, use this
  * helper function to make the compiler think we lock/unlock the @base variable,
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bart Van Assche

There are two versions of the __this_cpu_local_lock() definitions in include/linux/local_lock_internal.h: one version that relies on the Clang overloading functionality and another version that does not. Select the latter version when using sparse. This patch fixes the following errors reported by sparse:

Quoted 7 lines

include/linux/local_lock_internal.h:331:40: sparse: sparse: multiple definitions for function '__this_cpu_local_lock' include/linux/local_lock_internal.h:325:37: sparse: the previous one is here

Fixes d3febf16dee2 ("locking/local_lock: Support Clang's context analysis")
Quoted 17 lines
---
 include/linux/local_lock_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/local_lock_internal.h +1 -1
index eff711bf973f..234be7f12c15 100644
@@ -315,7 +315,7 @@ do {                                                                \
 
 #endif /* CONFIG_PREEMPT_RT */
 
-#if defined(WARN_CONTEXT_ANALYSIS)
+#if defined(WARN_CONTEXT_ANALYSIS) && !defined(__CHECKER__)
 /*
  * Because the compiler only knows about the base per-CPU variable, use this
  * helper function to make the compiler think we lock/unlock the @base variable,
#2 lore raw
In reply to Bart Van Assche
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     14de1552a4e3fece78bb20314887e70888c9d448
Gitweb:        https://git.kernel.org/tip/14de1552a4e3fece78bb20314887e70888c9d448
Author:        Bart Van Assche <[email protected]>
AuthorDate:    Wed, 11 Mar 2026 16:14:55 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 12 Mar 2026 11:29:11 +01:00

include/linux/local_lock_internal.h: Make this header file again compatible with sparse

There are two versions of the __this_cpu_local_lock() definitions in include/linux/local_lock_internal.h: one version that relies on the Clang overloading functionality and another version that does not. Select the latter version when using sparse. This patch fixes the following errors reported by sparse:

include/linux/local_lock_internal.h:331:40: sparse: sparse: multiple definitions for function '__this_cpu_local_lock' include/linux/local_lock_internal.h:325:37: sparse: the previous one is here

---
 include/linux/local_lock_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/local_lock_internal.h +1 -1
index eff711b..234be7f 100644
@@ -315,7 +315,7 @@ do {								\
 
 #endif /* CONFIG_PREEMPT_RT */
 
-#if defined(WARN_CONTEXT_ANALYSIS)
+#if defined(WARN_CONTEXT_ANALYSIS) && !defined(__CHECKER__)
 /*
  * Because the compiler only knows about the base per-CPU variable, use this
  * helper function to make the compiler think we lock/unlock the @base variable,