[PATCH v5 20/36] locking/ww_mutex: Support Clang's context analysis
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Mon Jan 12 10:32:25 UTC 2026
Hey,
The acquire_done() call was always optional. It's meant to indicate that after this point,
ww_acquire_lock may no longer be called and backoff can no longer occur.
It's allowed to call ww_acquire_fini() without ww_acquire_done()
Think of this case:
ww_acquire_init()
ww_acquire_lock_interruptible() -> -ERESTARTSYS
ww_acquire_fini()
Here it wouldn't make sense to call ww_acquire_done().
It's mostly to facilitate this case:
ww_acquire_init()
ww_acquire_lock() a bunch.
/* Got all locks, do the work as no more backoff occurs */
ww_acquire_done()
...
unlock_all()
ww_acquire_fini()
If you call ww_acquire_lock after done, a warning should occur as this should no longer happen.
Kind regards,
~Maarten Lankhorst
Den 2026-01-09 kl. 22:26, skrev Bart Van Assche:
> (+Maarten)
>
> On 1/9/26 2:06 PM, Marco Elver wrote:
>> If there's 1 out of N ww_mutex users that missed ww_acquire_done()
>> there's a good chance that 1 case is wrong.
>
> $ git grep -w ww_acquire_done '**c'|wc -l
> 11
> $ git grep -w ww_acquire_fini '**c'|wc -l
> 33
>
> The above statistics show that there are more cases where
> ww_acquire_done() is not called rather than cases where
> ww_acquire_done() is called.
>
> Maarten, since you introduced the ww_mutex code, do you perhaps prefer
> that calling ww_acquire_done() is optional or rather that all users that
> do not call ww_acquire_done() are modified such that they call
> ww_acquire_done()? The full email conversation is available here:
> https://lore.kernel.org/all/20251219154418.3592607-1-elver@google.com/
>
> Thanks,
>
> Bart.
More information about the Linux-security-module-archive
mailing list