[PATCH v6 1/5] rust: add generic static_key_false

Gary Guo gary at garyguo.net
Fri Aug 9 11:16:01 PDT 2024


On Thu, 08 Aug 2024 17:23:37 +0000
Alice Ryhl <aliceryhl at google.com> 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.
> 
> This patch only provides a generic implementation without code patching
> (matching the one used when CONFIG_JUMP_LABEL is disabled). Later
> patches add support for inline asm implementations that use runtime
> patching.
> 
> When CONFIG_JUMP_LABEL is unset, `static_key_count` is a static inline
> function, so a Rust helper is defined for `static_key_count` in this
> case. If Rust is compiled with LTO, this call should get inlined. The
> helper can be eliminated once we have the necessary inline asm to make
> atomic operations from Rust.
> 
> Signed-off-by: Alice Ryhl <aliceryhl at google.com>
> ---
>  rust/bindings/bindings_helper.h       |  1 +
>  rust/helpers.c                        |  9 +++++++++
>  rust/kernel/arch_static_branch_asm.rs |  1 +
>  rust/kernel/jump_label.rs             | 29 +++++++++++++++++++++++++++++
>  rust/kernel/lib.rs                    |  1 +
>  5 files changed, 41 insertions(+)
> 
> diff --git a/rust/kernel/arch_static_branch_asm.rs b/rust/kernel/arch_static_branch_asm.rs
> new file mode 100644
> index 000000000000..958f1f130455
> --- /dev/null
> +++ b/rust/kernel/arch_static_branch_asm.rs
> @@ -0,0 +1 @@
> +::kernel::concat_literals!("1: jmp " "{l_yes}" " # objtool NOPs this \n\t" ".pushsection __jump_table,  \"aw\" \n\t" " " ".balign 8" " " "\n\t" ".long 1b - . \n\t" ".long " "{l_yes}" "- . \n\t" " " ".quad" " " " " "{symb} + {off} + {branch}" " - . \n\t" ".popsection \n\t")


I believe this file is included by mistake, given it's added to
gitignore in patch 5.

Best,
Gary



More information about the linux-riscv mailing list