Re: [PATCH 1/2] rust: sync: refactor static_lock_class!() macro
From: Alice Ryhl
Date: Wed Jul 23 2025 - 15:58:40 EST
On Wed, Jul 23, 2025 at 6:20 PM Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
>
> On Wed, Jul 23, 2025 at 05:01:39PM +0200, Alice Ryhl wrote:
> > On Wed, Jul 23, 2025 at 4:36 PM Benno Lossin <lossin@xxxxxxxxxx> wrote:
> > >
> > > On Wed Jul 23, 2025 at 1:49 PM CEST, Alice Ryhl wrote:
> > > > impl LockClassKey {
> > > > + /// Initializes a statically allocated lock class key.
> > > > + ///
> > > > + /// This is usually used indirectly through the [`static_lock_class!`] macro.
> > > > + ///
> > > > + /// # Safety
> > > > + ///
> > > > + /// The destructor must never run on the returned `LockClassKey`.
> > >
> > > I don't know how lockdep works, but Boqun mentioned in the other thread
> > > that it uses the address of static keys. But AFAIK there is no mechanism
> > > to differentiate them, so does lockdep just check the address and if it
>
> In lockdep, we use `static_obj()` to tell whether it's a static obj or a
> dynamic allocated one.
Oh, ok. In that case I will adjust the safety comment.
Alice