Re: [PATCH 1/2] perf: arm_spe: Order padding before publishing AUX head

From: Will Deacon

Date: Tue Dec 01 2026 - 04:34:48 EST


On Fri, Nov 27, 2026 at 09:14:13PM +0000, Leo Yan wrote:
> On Fri, Nov 27, 2026 at 06:42:35PM +0000, Will Deacon wrote:
>
> > > @@ -487,8 +487,11 @@ static void arm_spe_pmu_pad_buf(struct perf_output_handle *handle, int len)
> > > u64 head = PERF_IDX2OFF(handle->head, buf);
> > >
> > > memset(buf->base + head, ARM_SPE_BUF_PAD_BYTE, len);
> > > - if (!buf->snapshot)
> > > + if (!buf->snapshot) {
> > > + /* Order the padding stores before publishing the new aux_head. */
> > > + smp_wmb();
> > > perf_aux_output_skip(handle, len);
> > > + }
> >
> > This looks correct to me, but I wonder if it should be handled by
> > perf_aux_output_skip() instead? arm_spe_pmu_pad_buf() is called from a
> > bunch of places in the driver, including in conjunction with
> > perf_aux_output_end(), which looks like it already has the necessary
> > memory barrier. So doing it here seems weird inconsistent to me.
>
> As I mentioned in the cover letter, the choice of barrier depends on the
> CPU memory model and the trace hardware. Perf deliberately leaves that
> choice to the AUX driver [1].

No it doesn't. The padding is written using store instructions from the
CPU, so they are ordered just like every other store instruction.

Will