[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aTA21F_fXA-xS34P@google.com>
Date: Wed, 3 Dec 2025 13:10:44 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: "Onur Özkan" <work@...rozkan.dev>
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 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?
> + // 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
Powered by blists - more mailing lists