Re: [PATCH v4 1/2] rust: add static_key_false
From: Alice Ryhl <aliceryhl@google.com>
Date: 2024-08-01 18:26:56
Also in:
linux-arch, linux-riscv, lkml, loongarch, rust-for-linux
From: Alice Ryhl <aliceryhl@google.com>
Date: 2024-08-01 18:26:56
Also in:
linux-arch, linux-riscv, lkml, loongarch, rust-for-linux
On Thu, Aug 1, 2024 at 12:28 PM Peter Zijlstra [off-list ref] wrote:
On Wed, Jul 31, 2024 at 11:34:13PM +0200, Alice Ryhl wrote:quoted
quoted
Please work harder to not have to duplicate stuff like this.I really didn't want to duplicate it, but it's very hard to find a performant alternative. Is there any way we could accept duplication only in the cases where an 'i' parameter is used? I don't have the choice of using a Rust helper for 'i' parameters. Perhaps one option could be to put the Rust code inside jump_label.h and have the header file evaluate to either C or Rust depending on the value of some #ifdefs? #ifndef RUST_ASM /* existing C code goes here */ #endif #ifdef RUST_ASM // rust code goes here #endif That way the duplication is all in a single file. It would also avoid the need for duplicating the nop5 string, as the Rust case is still going through the C preprocessor and can use the existing #define.I suppose that is slightly better, but ideally you generate the whole of the Rust thing from the C version. After all, Clang can already parse this. That said, with the below patch, I think you should be able to reuse the JUMP_TABLE_ENTRY macro like: JUMP_TABLE_ENTRY({0}, {1}, {2} + {3})
Yeah, I think this can work. I will submit a follow-up patch that removes the duplication soon. Alice