Re: [PATCH v3 4/9] x86: alternatives: macrofy locks for better inlining

From: Peter Zijlstra
Date: Mon Jun 11 2018 - 04:03:30 EST


On Sun, Jun 10, 2018 at 07:19:06AM -0700, Nadav Amit wrote:
> #ifdef CONFIG_SMP
> +.macro LOCK_PREFIX_HERE
> .pushsection .smp_locks,"a"
> .balign 4
> + .long 671f - . # offset
> .popsection
> +671:
> +.endm
> +
> +.macro LOCK_PREFIX insn:vararg
> + LOCK_PREFIX_HERE
> + lock \insn
> +.endm

Hurmph, the only reason we need to preserve that LOCK_PREFIX_HERE thing
is arch_cmpxchg64 in cmpxchg_32.h. Is there really no other way we can
write that one?

I suppose the problem with using LOCK_PREFIX inside the alternative is
that the .smp_locks fixup address gets computed wrong (inside the
alternative_text section instead of in the regular text)?

Oh well..