lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aFReIdlPPg4MmaYX@tardis.local>
Date: Thu, 19 Jun 2025 11:59:45 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Onur <work@...rozkan.dev>,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
	mingo@...hat.com, will@...nel.org, longman@...hat.com,
	ojeda@...nel.org, alex.gaynor@...il.com, gary@...yguo.net,
	bjorn3_gh@...tonmail.com, lossin@...nel.org, a.hindborg@...nel.org,
	tmgross@...ch.edu, dakr@...nel.org, thatslyude@...il.com
Subject: Re: [PATCH V3] implement `ww_mutex` abstraction for the Rust tree

On Thu, Jun 19, 2025 at 04:53:34PM +0200, Peter Zijlstra wrote:
> On Thu, Jun 19, 2025 at 04:44:01PM +0200, Alice Ryhl wrote:
> > On Thu, Jun 19, 2025 at 4:33 PM Onur <work@...rozkan.dev> wrote:
> > >
> > > On Thu, 19 Jun 2025 16:14:01 +0200
> > > Peter Zijlstra <peterz@...radead.org> wrote:
> > >
> > > > On Thu, Jun 19, 2025 at 05:06:56PM +0300, Onur Özkan wrote:
> > > > > +bool rust_helper_ww_mutex_is_locked(struct ww_mutex *lock)
> > > > > +{
> > > > > +   return ww_mutex_is_locked(lock);
> > > > > +}
> > > >
> > > > Do we really need this? In general I dislike all the _is_locked()
> > > > functions and would ideally like to remove them.
> > > >
> > > > Pretty much the only useful pattern for any of the _is_locked()
> > > > functions is:
> > > >
> > > >   WARN_ON_ONCE(!foo_is_locked(&foo));
> > > >
> > > > Any other use is dodgy as heck.
> > > >
> > > >
> > >
> > > It's an abstraction of `ww_mutex_is_locked`. Since this is an
> > > abstraction module, as long as `ww_mutex_is_locked` exists I think
> > > we should keep it. FWIW it's also quite useful for tests.
> > 
> > We're not just adding copies of all of the C methods - instead we
> > focus on the things we have a use-case for. If you're using them in

Agreed. And as Peter mentioned allowing a public API of is_locked()
doesn't make much sense.

> > tests, then that could make sense, but otherwise you shouldn't add
> > them.
> 
> It might make sense to include the assert in the method. That is,
> instead of providing .is_locked() that returns a boolean, have a void
> method .assert_is_locked() that traps if not locked.
> 

Moreover, we should also make it not public in the beginning if there is
no real user, which would still be usable in tests. I.e.

    impl<T: ..> WwMutex<'_, T> {
        fn assert_is_locked() { }
    }

Regards,
Boqun

> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ