[PATCH v3 1/2] rust: add static_key_false
Boqun Feng
boqun.feng at gmail.com
Thu Jun 27 09:26:46 PDT 2024
On Thu, Jun 27, 2024 at 10:34:39AM +0200, Alice Ryhl wrote:
> On Tue, Jun 25, 2024 at 6:18 PM Boqun Feng <boqun.feng at gmail.com> wrote:
> >
> > Hi Alice,
> >
> > On Fri, Jun 21, 2024 at 10:35:26AM +0000, Alice Ryhl wrote:
> > > Add just enough support for static key so that we can use it from
> > > tracepoints. Tracepoints rely on `static_key_false` even though it is
> > > deprecated, so we add the same functionality to Rust.
> > >
> > > It is not possible to use the existing C implementation of
> > > arch_static_branch because it passes the argument `key` to inline
> > > assembly as an 'i' parameter, so any attempt to add a C helper for this
> > > function will fail to compile because the value of `key` must be known
> > > at compile-time.
> > >
> > > Signed-off-by: Alice Ryhl <aliceryhl at google.com>
> >
> > [Add linux-arch, and related arch maintainers Cced]
> >
> > Since inline asms are touched here, please consider copying linux-arch
> > and arch maintainers next time ;-)
>
> Will do.
>
> > For x86_64 and arm64 bits:
> >
> > Acked-by: Boqun Feng <boqun.feng at gmail.com>
> >
> > One thing though, we should split the arch-specific impls into different
> > files, for example: rust/kernel/arch/arm64.rs or rust/arch/arm64.rs.
> > That'll be easier for arch maintainers to watch the Rust changes related
> > to a particular architecture.
>
> Is that how you would prefer to name these files? You don't want
> static_key somewhere in the filename?
>
I could have been more explicit. My preference is (for example ARM64)
* we have a rust/kernel/arch.rs, where we do:
#[cfg(CONFIG_ARM64)]
mod arm64::*;
#[cfg(CONFIG_ARM64)]
pub use arm64::*;
* we have a rust/kernel/arch/arm64.rs:
pub(crate) mod jump_label;
* we have a rust/kernel/arch/arm64/jump_label.rs, where we put
ARM64 arch_static_branch() there. (or static_key.rs and
arch_static_key_false()).
Then linux-arch can watch:
rust/kernel/arch.rs
rust/kernel/arch/
And ARM64 maintainers can watch:
rust/kernel/arch/arm64.rs
rust/kernel/arch/arm64
This is similar to how <asm/*.h> are organized today.
Does this make sense?
Regards,
Boqun
> > Another thought is that, could you implement an arch_static_branch!()
> > (instead of _static_key_false!()) and use it for static_key_false!()
> > similar to what we have in C? The benefit is that at least for myself
> > it'll be easier to compare the implementation between C and Rust.
>
> I can try to include that.
>
> Alice
More information about the linux-riscv
mailing list