[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251203190613.2771f9a8@nimda>
Date: Wed, 3 Dec 2025 19:06:13 +0300
From: Onur Özkan <work@...rozkan.dev>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: rust-for-linux@...r.kernel.org, lossin@...nel.org, lyude@...hat.com,
ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com,
gary@...yguo.net, a.hindborg@...nel.org, tmgross@...ch.edu,
dakr@...nel.org, peterz@...radead.org, mingo@...hat.com, will@...nel.org,
longman@...hat.com, felipe_life@...e.com, daniel@...lak.dev,
daniel.almeida@...labora.com, thomas.hellstrom@...ux.intel.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 4/6] rust: implement Class for ww_class support
On Wed, 3 Dec 2025 13:10:44 +0000
Alice Ryhl <aliceryhl@...gle.com> wrote:
> On Mon, Dec 01, 2025 at 01:28:53PM +0300, Onur Özkan wrote:
> > Adds the Class type, the first step in supporting
> > ww_mutex in Rust. Class represents ww_class, used
> > for deadlock avoidance for supporting both wait-die
> > and wound-wait semantics.
> >
> > Also adds the define_class macro for safely declaring
> > static instances.
>
> > +impl Class {
> > + /// Creates an unpinned [`Class`].
> > + ///
> > + /// # Safety
> > + ///
> > + /// Caller must guarantee that the returned value is not moved
> > after creation.
>
> The value is moved when you return it. Perhaps you meant that it must
> be pinned before first use?
>
Yes, that was my point.
> > + // TODO: Replace with
> > `bindings::lock_class_key::default()` once
> > + // stabilized for `const`.
> > + //
> > + // SAFETY: This is always
> > zero-initialized when defined with
> > + // `DEFINE_WD_CLASS` globally on C
> > side.
> > + //
> > + // For reference, see
> > __WW_CLASS_INITIALIZER() in
> > + // "include/linux/ww_mutex.h".
> > + acquire_key: core::mem::zeroed(),
> > + mutex_key: core::mem::zeroed(),
>
> For global lock class keys, this is fine, but this constructor seems
> to be for the non-global case. In that case, lockdep_register_key()
> must be called.
>
> Is a ww_class ever created as a non-global? I don't really think so.
> If not, then let's not support it.
>
> Alice
No, it's always used as global on the C side. Good point, will make the
change in the next version.
-Onur
Powered by blists - more mailing lists