Re: [PATCH] include/linux/local_lock_internal.h: Make this header file again compatible with sparse
From: Marco Elver
Date: Wed Mar 11 2026 - 20:24:52 EST
On Thu, 12 Mar 2026 at 00:15, Bart Van Assche <bvanassche@xxxxxxx> wrote:
>
> 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
>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202603062334.wgI5htP0-lkp@xxxxxxxxx/
> Fixes: d3febf16dee2 ("locking/local_lock: Support Clang's context analysis")
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
Reviewed-by: Marco Elver <elver@xxxxxxxxxx>
> ---
> include/linux/local_lock_internal.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
> index eff711bf973f..234be7f12c15 100644
> --- a/include/linux/local_lock_internal.h
> +++ b/include/linux/local_lock_internal.h
> @@ -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,