# Re: \[PATCH v10 5/5\] rust: add arch\_static\_branch

- From: Alice Ryhl \<aliceryhl@google.com\>
- Date: 2024-10-15 13:06:03 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2024/10/2783666
- Thread: https://ratatoskr.run/linux-trace-kernel/2024/10/2778864/t.md

```text
On Fri, Oct 11, 2024 at 5:24 PM Josh Poimboeuf [ref] wrote:
>
> On Fri, Oct 11, 2024 at 10:13:38AM +0000, Alice Ryhl wrote:
> > +#[cfg(CONFIG_JUMP_LABEL)]
> > +#[cfg(not(CONFIG_HAVE_JUMP_LABEL_HACK))]
> > +macro_rules! arch_static_branch {
> > +    ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
> > +        $crate::asm!(
> > +            include!(concat!(env!("OBJTREE"), "/rust/kernel/arch_static_branch_asm.rs"));
> > +            l_yes = label {
> > +                break 'my_label true;
> > +            },
> > +            symb = sym $key,
> > +            off = const ::core::mem::offset_of!($keytyp, $field),
> > +            branch = const $crate::jump_label::bool_to_int($branch),
> > +        );
> > +
> > +        break 'my_label false;
> > +    }};
> > +}
> > +
> > +#[macro_export]
> > +#[doc(hidden)]
> > +#[cfg(CONFIG_JUMP_LABEL)]
> > +#[cfg(CONFIG_HAVE_JUMP_LABEL_HACK)]
> > +macro_rules! arch_static_branch {
> > +    ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
> > +        $crate::asm!(
> > +            include!(concat!(env!("OBJTREE"), "/rust/kernel/arch_static_branch_asm.rs"));
> > +            l_yes = label {
> > +                break 'my_label true;
> > +            },
> > +            symb = sym $key,
> > +            off = const ::core::mem::offset_of!($keytyp, $field),
> > +            branch = const 2 | $crate::jump_label::bool_to_int($branch),
> > +        );
> > +
> > +        break 'my_label false;
> > +    }};
>
> Ouch... could we get rid of all this duplication by containing the hack
> bit to ARCH_STATIC_BRANCH_ASM() like so?

Good idea, thanks.

Alice
```
