Re: [PATCH v12 2/6] ww_mutex: add ww_class field unconditionally
From: Onur Özkan
Date: Thu Oct 15 2026 - 07:40:21 EST
On Mon, 12 Oct 2026 12:42:31 +0100
Gary Guo <gary@xxxxxxxxxxx> wrote:
> On Mon Oct 12, 2026 at 11:26 AM BST, Onur Özkan wrote:
> > Removes DEBUG_WW_MUTEXES guard around the ww_class field
> > in struct ww_mutex and struct ww_acquire_ctx to always
> > initialize it.
> >
> > Keeping the class pointer available unconditionally allows
> > Rust abstractions to keep from_raw() simple on Mutex and
> > AcquireCtx and validate Mutex and AcquireCtx class pairing
> > in much simpler way.
>
> Is a mismatch a memory safety issue or just a bug?
ww_mutex_lock_acquired() explicitly calls it as an UB:
/*
* Naughty, using a different class will lead to undefined behavior!
*/
DEBUG_LOCKS_WARN_ON(ww_ctx->ww_class != ww->ww_class);
Thanks,
Onur
>
> Best,
> Gary
>
> >
> > Link: https://lore.kernel.org/all/ECC0425A-8B18-4626-8EA8-2F843C45E0A1@xxxxxxxxxxxxx/
> > Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> > Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> > Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
>