[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBVLEGFYBWKE.2RW8J853CJHTY@kernel.org>
Date: Wed, 06 Aug 2025 21:30:27 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Lyude Paul" <lyude@...hat.com>, Onur Özkan
<work@...rozkan.dev>
Cc: <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
<ojeda@...nel.org>, <alex.gaynor@...il.com>, <boqun.feng@...il.com>,
<gary@...yguo.net>, <a.hindborg@...nel.org>, <aliceryhl@...gle.com>,
<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>, <bjorn3_gh@...tonmail.com>
Subject: Re: [PATCH v5 0/3] rust: add `ww_mutex` support
On Wed Aug 6, 2025 at 7:37 PM CEST, Lyude Paul wrote:
> On Wed, 2025-08-06 at 08:57 +0300, Onur Özkan wrote:
>> Thanks for the feedback! Supporting single locks is easy, I just
>> didn't think it was a good idea at first but it looks like I missed
>> some cases.
>>
>> I can implement two types of locking functions: one on `WwMutex` where
>> `WwMutex::lock` handles a single lock without a context, and another on
>> `WwAcquireCtx`, where `WwAcquireCtx::lock` is used for handling
>> multiple contexts.
>>
>> e.g.,:
>>
>> let mutex = WwMutex::new(...);
>> mutex.lock(); // without context, for single locks
>>
>> let ctx = WwAcquireCtx::new(...);
>> ctx.lock(mutex); // with context, for multiple locks
>>
>> What do you think?
>
> Yeah I think this works great! One thing I'm curious about: as was previously
> mentioned in the thread, when there's no lock context a ww_mutex is basically
> identical to a mutex. Which makes me wonder if maybe it would make sense to
> actually implement ww_mutex as a kernel::sync::Backend exclusively for ctx-
> free lock acquisitions, and then simply implement locking with contexts
> through WwAcquireCtx. That way we at least get to reuse some of the locking
> infrastructure we already have in rust without overcomplicating it for
> everyone else.
We're going away from the generic lock framework, so I don't think we
should add any new `Backend`s.
---
Cheers,
Benno
Powered by blists - more mailing lists