[PATCH 0/3] Remove the usage of Rust native atomics in debugfs

Boqun Feng posted 3 patches 3 months, 2 weeks ago
rust/kernel/debugfs/traits.rs       | 53 +++++++++--------------------
rust/kernel/sync/atomic.rs          | 12 ++++++-
samples/rust/rust_debugfs.rs        | 12 +++----
samples/rust/rust_debugfs_scoped.rs |  6 ++--
4 files changed, 36 insertions(+), 47 deletions(-)
[PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Boqun Feng 3 months, 2 weeks ago
Rust native atomics are not supposed to be used in kernel due to the
mismatch of memory model, since we now have the LKMM atomics in Rust,
remove the usage of Rust native atomics in debugfs.

(help is appreciated if anyone wants to help in other subsystem)

Boqun Feng (3):
  rust: sync: atomic: Make Atomic*Ops pub(crate)
  rust: sync: atomic: Implement Debug for Atomic<Debug>
  rust: debugfs: Replace the usage of Rust native atomics

 rust/kernel/debugfs/traits.rs       | 53 +++++++++--------------------
 rust/kernel/sync/atomic.rs          | 12 ++++++-
 samples/rust/rust_debugfs.rs        | 12 +++----
 samples/rust/rust_debugfs_scoped.rs |  6 ++--
 4 files changed, 36 insertions(+), 47 deletions(-)

-- 
2.51.0
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Danilo Krummrich 3 months, 2 weeks ago
On 10/22/25 5:53 AM, Boqun Feng wrote:
> Boqun Feng (3):
>   rust: sync: atomic: Make Atomic*Ops pub(crate)
>   rust: sync: atomic: Implement Debug for Atomic<Debug>
>   rust: debugfs: Replace the usage of Rust native atomics

I ack'd patch three for you to pick it up, but I now wonder if you want me to
pick it up through the driver-core tree?
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Boqun Feng 3 months ago
On Fri, Oct 24, 2025 at 04:57:22PM +0200, Danilo Krummrich wrote:
> On 10/22/25 5:53 AM, Boqun Feng wrote:
> > Boqun Feng (3):
> >   rust: sync: atomic: Make Atomic*Ops pub(crate)
> >   rust: sync: atomic: Implement Debug for Atomic<Debug>
> >   rust: debugfs: Replace the usage of Rust native atomics
> 
> I ack'd patch three for you to pick it up, but I now wonder if you want me to

Thanks!

> pick it up through the driver-core tree?

Given there are some atomic library changes, I will send it as a PR to
tip. Thanks for the offering!

Regards,
Boqun
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Greg Kroah-Hartman 3 months, 2 weeks ago
On Tue, Oct 21, 2025 at 11:53:21PM -0400, Boqun Feng wrote:
> Rust native atomics are not supposed to be used in kernel due to the
> mismatch of memory model, since we now have the LKMM atomics in Rust,
> remove the usage of Rust native atomics in debugfs.
> 
> (help is appreciated if anyone wants to help in other subsystem)
> 
> Boqun Feng (3):
>   rust: sync: atomic: Make Atomic*Ops pub(crate)
>   rust: sync: atomic: Implement Debug for Atomic<Debug>
>   rust: debugfs: Replace the usage of Rust native atomics
> 
>  rust/kernel/debugfs/traits.rs       | 53 +++++++++--------------------
>  rust/kernel/sync/atomic.rs          | 12 ++++++-
>  samples/rust/rust_debugfs.rs        | 12 +++----
>  samples/rust/rust_debugfs_scoped.rs |  6 ++--
>  4 files changed, 36 insertions(+), 47 deletions(-)
> 
> -- 
> 2.51.0
> 
> 

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Peter Zijlstra 3 months, 2 weeks ago
On Tue, Oct 21, 2025 at 11:53:21PM -0400, Boqun Feng wrote:
> Rust native atomics are not supposed to be used in kernel due to the
> mismatch of memory model, since we now have the LKMM atomics in Rust,
> remove the usage of Rust native atomics in debugfs.

Doesn't rust have a language feature that allows you to blacklist them;
ensuring they are not used?
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Boqun Feng 3 months, 2 weeks ago
On Wed, Oct 22, 2025 at 10:07:17AM +0200, Peter Zijlstra wrote:
> On Tue, Oct 21, 2025 at 11:53:21PM -0400, Boqun Feng wrote:
> > Rust native atomics are not supposed to be used in kernel due to the
> > mismatch of memory model, since we now have the LKMM atomics in Rust,
> > remove the usage of Rust native atomics in debugfs.
> 
> Doesn't rust have a language feature that allows you to blacklist them;
> ensuring they are not used?
> 

Although I don't know whether it's available today, but I believe that
can be done (in the future probably?).

However, this patchset is about cleaning up the existing usage, which
was introduced before we have LKMM atomics on the Rust side.

Regards,
Boqun

>
Re: [PATCH 0/3] Remove the usage of Rust native atomics in debugfs
Posted by Alice Ryhl 3 months, 2 weeks ago
On Wed, Oct 22, 2025 at 10:07:17AM +0200, Peter Zijlstra wrote:
> On Tue, Oct 21, 2025 at 11:53:21PM -0400, Boqun Feng wrote:
> > Rust native atomics are not supposed to be used in kernel due to the
> > mismatch of memory model, since we now have the LKMM atomics in Rust,
> > remove the usage of Rust native atomics in debugfs.
> 
> Doesn't rust have a language feature that allows you to blacklist them;
> ensuring they are not used?

I believe clippy lets you do that.

Alice