From: Will Deacon <will@kernel.org>
To: Leo Yan <leo.yan@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
James Clark <james.clark@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] perf: arm_spe: Correct setting the PERF_HES_STOPPED flag
Date: Thu, 8 Jan 2026 16:23:58 +0000 [thread overview]
Message-ID: <aV_aHi9BLFzjnmx7@willie-the-truck> (raw)
In-Reply-To: <20251125142036.GE724103@e132581.arm.com>
On Tue, Nov 25, 2025 at 02:20:36PM +0000, Leo Yan wrote:
> On Mon, Nov 24, 2025 at 07:02:06PM +0000, Will Deacon wrote:
>
> [...]
>
> > > > If __arm_spe_pmu_next_off() fails, it will call perf_aux_output_end()
> > > > with the TRUNCATED flag set, which should then disable the event
> > > > via arm_spe_pmu_del() and update the state there.
> > > >
> > > > Is that not happening?
> > >
> > > Correct. However, this patch is not for the flow you mentioned.
> >
> > How is it not for this flow? You're talking about:
> >
> > arm_spe_pmu_start
> > => arm_spe_perf_aux_output_begin
> > => arm_spe_pmu_next_off // Returns error
> >
> > The only way arm_spe_pmu_next_off() returns an error is if
> > __arm_spe_pmu_next_off() fails, and that's the flow I'm talking about.
>
> My bad. Because you mentioned the TRUNCATED flag, I incorrectly assumed
> it had to be used in interrupt handler with the disable irq work.
>
> > > If an error is returned from arm_spe_pmu_next_off(), because hw.state
> > > is not set to PERF_HES_STOPPED, the caller arm_spe_pmu_start() cannot
> > > detect error properly:
> >
> > But why isn't PERF_HES_STOPPED set by the sequence I described?
>
> Fair point. I can confirm after settting the TRUNCATED flag,
> arm_spe_pmu_del() will be invoked to disable the trace unit and state
> will be updated to PERF_HES_STOPPED.
>
> > I have a feeling you're right, but I can't piece it together from the
> > information here.
>
> Let me explain in another way:
>
> The issue is a mismatch between the state machine and the hardware
> state. When arm_spe_perf_aux_output_begin() detects an error and does
> not set PMBLIMITR_EL1_E, the trace unit is effectively stopped, but
> the state machine is not updated to PERF_HES_STOPPED. This causes
> callers to handle errors incorrectly [1][2].
>
> It is arguable that the disable IRQ work will eventually disable the
> trace unit and update hw.state, but the state should be updated in the
> first place by the PMU driver to notify even core layer.
From what I can tell, perf_aux_output_end() will call
perf_event_disable_inatomic() which should end up invoking
perf_pending_disable() via an IPI-to-self to disable the event and put
it in the PERF_HES_STOPPED state before we return to userspace.
So I still struggle to see the problem here.
Will
next prev parent reply other threads:[~2026-01-08 16:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 16:28 [PATCH v2 0/2] perf: arm_spe: Fix trace disabling for invalid limits Leo Yan
2025-11-10 16:28 ` [PATCH v2 1/2] perf: arm_spe: Correct setting the PERF_HES_STOPPED flag Leo Yan
2025-11-24 16:14 ` Will Deacon
2025-11-24 18:48 ` Leo Yan
2025-11-24 18:54 ` Leo Yan
2025-11-24 19:02 ` Will Deacon
2025-11-25 14:20 ` Leo Yan
2026-01-08 16:23 ` Will Deacon [this message]
2026-01-14 17:52 ` Leo Yan
2026-01-20 16:42 ` Will Deacon
2026-01-20 18:15 ` Leo Yan
2025-11-10 16:28 ` [PATCH v2 2/2] perf: arm_spe: Ensure profiling buffer is properly disabled Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aV_aHi9BLFzjnmx7@willie-the-truck \
--to=will@kernel.org \
--cc=alexandru.elisei@arm.com \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox