Re: [PATCH 03/13] jump_label/x86: Avoid decoding instructions for jump entry size
From: Jiri Olsa
Date: Thu Nov 12 2026 - 13:49:54 EST
On Thu, Nov 12, 2026 at 09:39:45AM +0100, Peter Zijlstra wrote:
> On Mon, Nov 09, 2026 at 08:49:06PM +0100, Jiri Olsa wrote:
>
> > int arch_jump_entry_size(struct jump_entry *entry)
> > {
> > + const u8 *code = (void *)jump_entry_code(entry);
> >
> > + if (code[0] == JMP8_INSN_OPCODE ||
> > + !memcmp(code, x86_nops[JMP8_INSN_SIZE], JMP8_INSN_SIZE))
> > + return JMP8_INSN_SIZE;
> >
> > + if (code[0] == JMP32_INSN_OPCODE ||
> > + !memcmp(code, x86_nops[JMP32_INSN_SIZE], JMP32_INSN_SIZE))
> > + return JMP32_INSN_SIZE;
> > +
> > + BUG();
> > }
>
> Does this actually generate sane code and checks code[0] first for both
> values before it goes and does memcmp() ? The naive translation would
> suggest it does not.
>
nope.. you're right, I'll make it explicit
thanks,
jirka