Re: [PATCH 14/20] x86/barrier: Use alternative_io() in 32-bit barrier functions
From: Josh Poimboeuf
Date: Fri Mar 14 2025 - 20:05:43 EST
On Fri, Mar 14, 2025 at 01:49:48PM -1000, Linus Torvalds wrote:
> So all of these patches look like good cleanups to me, but I do wonder
> if we should
>
> (a) not use some naming *quite* as generic as 'ARG()'
>
> (b) make the asms use ARG_OUT/ARG_IN/ARG_CLOBBER() to clarify
>
> because that ARG(), ARG(), ARGC() pattern looks odd to me.
>
> Maybe it's just me.
>
> Regardless, I do think the series looks like a nice improvement even
> in the current form, even if that particular repeated pattern feels
> strange.
So originally I had ASM_OUTPUT/ASM_INPUT/ASM_CLOBBER, but I ended up
going with ARG() due to its nice vertical alignment and conciseness:
__asm_call(qual, \
ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \
"cmpxchg8b " __percpu_arg([var]), \
X86_FEATURE_CX8), \
ARG([var] "+m" (__my_cpu_var(_var)), "+a" (old__.low), \
"+d" (old__.high)), \
ARG("b" (new__.low), "c" (new__.high), "S" (&(_var))), \
ARG("memory")); \
Though ASM_OUTPUT/ASM_INPUT/ASM_CLOBBER isn't so bad either:
__asm_call(qual, \
ALTERNATIVE("call this_cpu_cmpxchg8b_emu", \
"cmpxchg8b " __percpu_arg([var]), \
X86_FEATURE_CX8), \
ASM_OUTPUT([var] "+m" (__my_cpu_var(_var)), \
"+a" (old__.low), "+d" (old__.high)), \
ASM_INPUT("b" (new__.low), "c" (new__.high), \
"S" (&(_var))), \
ASM_CLOBBER("memory")); \
That has the nice benefit of being more self-documenting, albeit more
verbose and less vertically aligned.
So I could go either way, really.
--
Josh