On Fri, Aug 9, 2024 at 8:16 PM Gary Guo [off-list ref] wrote:
On Thu, 08 Aug 2024 17:23:37 +0000
Alice Ryhl [off-list ref] wrote:
quoted
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@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.
We may have to rethink the file extension used here. You have no idea
how many times I've deleted that file from this commit.
Alice