Re: [PATCH v2 01/34] compiler_types: Move lock checking attributes to compiler-capability-analysis.h

From: Dan Carpenter
Date: Wed Mar 05 2025 - 03:36:27 EST


On Tue, Mar 04, 2025 at 10:21:00AM +0100, Marco Elver wrote:
> +#ifndef _LINUX_COMPILER_CAPABILITY_ANALYSIS_H
> +#define _LINUX_COMPILER_CAPABILITY_ANALYSIS_H
> +
> +#ifdef __CHECKER__
> +
> +/* Sparse context/lock checking support. */
> +# define __must_hold(x) __attribute__((context(x,1,1)))
> +# define __acquires(x) __attribute__((context(x,0,1)))
> +# define __cond_acquires(x) __attribute__((context(x,0,-1)))
> +# define __releases(x) __attribute__((context(x,1,0)))
> +# define __acquire(x) __context__(x,1)
> +# define __release(x) __context__(x,-1)
> +# define __cond_lock(x, c) ((c) ? ({ __acquire(x); 1; }) : 0)
> +

The other thing you might want to annotate is ww_mutex_destroy().

I'm happy about the new __guarded_by annotation.

regards,
dan carpenter