Re: [RFC][PATCH 2/4] locking/mutex: Add context analysis

From: Peter Zijlstra

Date: Wed Jan 21 2026 - 13:59:21 EST


On Wed, Jan 21, 2026 at 09:11:53AM -0800, Bart Van Assche wrote:
> On 1/21/26 3:07 AM, Peter Zijlstra wrote:
> > @@ -565,6 +574,8 @@ EXPORT_SYMBOL(mutex_unlock);
> > * of a unlocked mutex is not allowed.
> > */
> > void __sched ww_mutex_unlock(struct ww_mutex *lock)
> > + __releases(lock)
> > + __no_context_analysis
> > {
> > __ww_mutex_unlock(lock);
> > mutex_unlock(&lock->base);
>
> "__releases()" annotations should be added to the declaration of a
> function only instead of the definition, isn't it?
>
> > @@ -824,22 +838,27 @@ EXPORT_SYMBOL(ww_mutex_trylock);
> > #ifdef CONFIG_DEBUG_LOCK_ALLOC
> > void __sched
> > mutex_lock_nested(struct mutex *lock, unsigned int subclass)
> > + __acquires(lock)
>
> Same comment here and below for the "__acquires()" annotation: I think
> this annotation should be added to the function declaration only.

Yeah, I thought I went through and lifted most of them. Clearly I missed
a few :/