[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aFnNK1zE_IvLKsaa@tardis.local>
Date: Mon, 23 Jun 2025 14:54:51 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Onur <work@...rozkan.dev>
Cc: linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
ojeda@...nel.org, alex.gaynor@...il.com, gary@...yguo.net,
lossin@...nel.org, 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 2/3] implement ww_mutex abstraction for the Rust tree
On Mon, Jun 23, 2025 at 09:17:40PM +0300, Onur wrote:
> > [...]
> > > + /// Checks if the mutex is currently locked.
> > > + pub fn is_locked(&self) -> bool {
> >
> > Did I miss a reply from you regarding:
> >
> > https://lore.kernel.org/rust-for-linux/aFReIdlPPg4MmaYX@tardis.local/
> >
> > no public is_lock() please. Do an assert_is_locked() instead. We need
> > to avoid users from abusing this.
>
> Sorry, I missed that. Perhaps, using `#[cfg(CONFIG_KUNIT)]` e.g.,:
>
As long as it's not `pub`, it's fine. `#[cfg(CONFIG_KUNIT)]` is not
needed.
> /// Checks if the mutex is currently locked.
Please mention that the function is only for internal testing, and
cannot be used to check whether another task has acquired an lock or
not.
Thanks!
Regards,
Boqun
> #[cfg(CONFIG_KUNIT)]
> fn is_locked(&self) -> bool {
> // SAFETY: The mutex is pinned and valid.
> unsafe { bindings::ww_mutex_is_locked(self.mutex.get()) }
> }
>
> would be better? What do you think?
[..]
Powered by blists - more mailing lists