Re: [PATCH v2 1/1] alpha: Add support for HAVE_ARCH_JUMP_LABEL

From: Matt Turner

Date: Thu Oct 08 2026 - 16:49:34 EST


On Wed, Feb 25, 2026 at 12:02 PM Magnus Lindholm <linmag7@xxxxxxxxx> wrote:
> Implement static key (jump label) support for Alpha.

Sorry for the slow review. This looks correct to me. I applied it to
your for-next (the arch/alpha/Kconfig hunk needs a trivial rebase) and
it builds cleanly with W=1, CONFIG_JUMP_LABEL=y and
CONFIG_STATIC_KEYS_SELFTEST=y. I have not booted it. A few comments,
none of them blocking:

> + select HAVE_ARCH_JUMP_LABEL

Please keep the select list sorted.

> +static inline void alpha_patch_text(u32 *site, u32 insn)
> +{
> + WRITE_ONCE(*site, insn);
> + flush_icache_range((unsigned long)site, (unsigned long)site + sizeof(*site));

On SMP flush_icache_range() is smp_imb(), so this is one
on_each_cpu() IPI round per patched site. A key with many sites, or
a module load, turns into that many broadcasts. That is fine as a
first version, but it would be worth a follow-up that implements
arch_jump_label_transform_queue()/_apply() (HAVE_JUMP_LABEL_BATCH)
so that a key update does a single imb at the end.

> + if (disp < -(1L << 20) || disp > ((1L << 20) - 1)) {
> + WARN_ON_ONCE(1);
> + disp = 0;
> + }

With disp = 0 we write a branch to the next instruction, so the site
silently behaves as a NOP. I would rather return without patching (or
BUG) than install something that looks valid. The comment about what
other architectures do can go.

> +struct jump_entry {
> + jump_label_t code;
> + jump_label_t target;
> + jump_label_t key;
> +};

Optional: HAVE_ARCH_JUMP_LABEL_RELATIVE would shrink this from 24 to
16 bytes per entry, and the module loader already handles
R_ALPHA_SREL32 and R_ALPHA_SREL64. Fine to leave for later.

Small things:
- <linux/mutex.h> is unused in jump_label.c.
- JUMP_LABEL_NOP_SIZE is unused.
- ALPHA_INSN_NOP has two trailing comments.
- There is a stray double blank line before the include guard.
- The commit message could note that this relies on kernel and
module text being writable (no STRICT_KERNEL_RWX on alpha).

Did you run CONFIG_STATIC_KEYS_SELFTEST, and load and unload a module
that carries static keys?

Reviewed-by: Matt Turner <mattst88@xxxxxxxxx>