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

From: Leo Yan

Date: Fri Nov 27 2026 - 16:14:21 EST


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].

SPE driver implicitly relies on the dsb(nsh) in
arm_spe_pmu_disable_and_drain_local() to make trace writes visible
before calling perf_aux_output_end(). I kept the barrier in the driver
for perf_aux_output_skip() to follow the same convention.

Thanks,
Leo

[1] https://lore.kernel.org/all/YLUFMzxin1PpgIdZ@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/