Re: [RFC PATCH 06/13] arm64: percpu: Add infrastructure for preemptible this_cpu_*() ops
From: Mark Rutland
Date: Thu Jul 30 2026 - 07:03:21 EST
On Wed, Jul 29, 2026 at 03:25:52PM +0100, Vladimir Murzin wrote:
> On 7/28/26 13:38, Mark Rutland wrote:
> > +#define __VAL_PCPU_GPRS(pcp, off, addr) \
> > + "(" \
> > + "(.L__gpr_num_" pcp " << 0) | " \
> > + "(.L__gpr_num_" off " << 5) | " \
> > + "(.L__gpr_num_" addr " << 10)" \
> > + ")"
>
> Later in the patch, there is a comment stating that these registers
> are not expected to overlap. I can also see that early-clobber
> constraints are applied to the output registers later in the patch
> series, so the code is correct.
>
> However, would it be possible to add assertions that detect register
> overlap, perhaps something like:
>
> ".if (.L__gpr_num_" pcp "== .L__gpr_num_" off ") ||" \
> " (.L__gpr_num_" pcp "== .L__gpr_num_" addr ") ||" \
> " (.L__gpr_num_" off "== .L__gpr_num_" addr")" \
> ".error "inline asm registers overlap" \
> ".endif" \
That's a good idea. I've added the following:
| #define __ASSERT_PCPU_GPRS_UNIQUE(pcp, off, addr) \
| ".if (" \
| "(.L__gpr_num_" pcp " == .L__gpr_num_" off ") || " \
| "(.L__gpr_num_" pcp " == .L__gpr_num_" addr ") || " \
| "(.L__gpr_num_" off " == .L__gpr_num_" addr")" \
| " )\n" \
| ".error \"PCPU GPRS overlap: {" pcp "," off "," addr "}\"\n" \
| ".endif\n"
|
| #define ____PCPU_GPRS_BEGIN(gprs, pcp, off, addr) \
| __DEFINE_ASM_GPR_NUMS \
| __DEFINE_ASM_GPR_ALIASES \
| __ASSERT_PCPU_GPRS_UNIQUE(pcp, off, addr) \
| " mov w" off ", #" __VAL_PCPU_GPRS(pcp, off, addr) "\n" \
| " strh w" off ", " gprs "\n" \
| __KERN_ASM_CPU_OFFSET(off) "\n"
With that, we have enough ".L__gpr_num_" string concatenation that we
should probably have:
| #define __GPR_NUM(r) "(.L__gpr_num_" r ")"
... so I'll go add a preparatory patches adding that and cleaning up
existing usage.
Mark.