Re: [WIP 1/3] rust: Introduce atomic module
From: Trevor Gross
Date: Tue Mar 26 2024 - 01:57:16 EST
On Sat, Mar 23, 2024 at 10:10 AM Andrew Lunn <andrew@xxxxxxx> wrote:
> > > Is it possible to somehow poison rusts own atomics? I would not be
> > > too surprised if somebody with good Rust knowledge but new to the
> > > kernel tries using Rusts atomics. Either getting the compiler to fail
> > > the build, or it throws an Opps on first invocation would be good.
> >
> > We could try to get a flag added to the Rust standard library that
> > removes the core::sync::atomic module entirely, then pass that flag.
>
> Just looking down the road a bit, are there other features in the
> standard library which are not applicable to Linux kernel space?
> Ideally we want a solution not just for atomics but a generic solution
> which can disable a collection of features? Maybe one by one?
Clippy is an easy way to do this via the disallowed_* lints.
disallowed_types [1] would be applicable here to forbid
`core::atomic::Atomic*`.
I don't think KCI currently checks clippy, but we probably want that
at some point.
- Trevor
[1]: https://rust-lang.github.io/rust-clippy/master/index.html#/disallowed_types
> And i assume somebody will try to use Rust in uboot/barebox. It
> probably has similar requirements to the Linux kernel? But what about
> Zephyr? Or VxWorks? Darwin?
>
> Andrew
>