* [PATCH 0/3] perf: Suppress redundant ITRACE start records for Arm SPE and CoreSight
@ 2026-09-01 16:36 Leo Yan
2026-09-01 16:36 ` [PATCH 1/3] perf/core: Export perf_event_itrace_started() Leo Yan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Leo Yan @ 2026-09-01 16:36 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Suzuki K Poulose,
Mark Rutland, Adrian Hunter, James Clark, Mike Leach, Tamas Petz,
Tamas Zsoldos
Cc: linux-perf-users, linux-kernel, linux-arm-kernel, coresight,
Leo Yan
Thanks to Tamas Petz for noticing that Arm CoreSight perf data can contain
many PERF_RECORD_ITRACE_START records.
PERF_RECORD_ITRACE_START provides the decoder with the initial thread
context when that information is absent from the trace stream. Once
tracing has started, Arm SPE and CoreSight decoders track subsequent
context changes using context packets or recorded sched_switch events.
Have both drivers call perf_event_itrace_started() after successfully
starting event. This prevents perf core from emitting redundant
PERF_RECORD_ITRACE_START records when an event is scheduled in again.
Since the Arm SPE and CoreSight drivers can be built as modules, export
perf_event_itrace_started() before using it in those drivers.
This series was verified with Arm CoreSight using the commands below.
The perf data contains 100 sched_switch events but only one
PERF_RECORD_ITRACE_START record:
taskset -c 2 perf record -e cs_etm//u -e sched:sched_switch -- \
taskset -c 2 bash -c 'while true; do sleep 0.01; done'
^C
perf script -D 2>&1 | grep -c sched_switch
100
perf script -D 2>&1 | grep -c PERF_RECORD_ITRACE_START
1
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Leo Yan (3):
perf/core: Export perf_event_itrace_started()
perf: arm_spe: Suppress redundant ITRACE start records
coresight: perf: Suppress ITRACE start records
drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++
drivers/perf/arm_spe_pmu.c | 2 ++
kernel/events/core.c | 1 +
3 files changed, 5 insertions(+)
---
base-commit: 786262be6048deab760f68c8acc2c85607165894
change-id: 20260901-perf_suppress_itrace_start_records-42faf45e9ce9
Best regards,
--
Leo Yan <leo.yan@arm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] perf/core: Export perf_event_itrace_started()
2026-09-01 16:36 [PATCH 0/3] perf: Suppress redundant ITRACE start records for Arm SPE and CoreSight Leo Yan
@ 2026-09-01 16:36 ` Leo Yan
2026-09-01 16:48 ` sashiko-bot
2026-09-01 16:36 ` [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records Leo Yan
2026-09-01 16:36 ` [PATCH 3/3] coresight: perf: Suppress " Leo Yan
2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-01 16:36 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Suzuki K Poulose,
Mark Rutland, Adrian Hunter, James Clark, Mike Leach, Tamas Petz,
Tamas Zsoldos
Cc: linux-perf-users, linux-kernel, linux-arm-kernel, coresight,
Leo Yan
Since Arm SPE and CoreSight drivers can be built as modules, export
perf_event_itrace_started() so that it can be used by these modules.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
kernel/events/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a6c8e38a311042afab6b65814a84c67b87ba929b..8afe89179a62127eebae0f38f29cde045ba56251 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10560,6 +10560,7 @@ void perf_event_itrace_started(struct perf_event *event)
{
WRITE_ONCE(event->attach_state, event->attach_state | PERF_ATTACH_ITRACE);
}
+EXPORT_SYMBOL_GPL(perf_event_itrace_started);
static void perf_log_itrace_start(struct perf_event *event)
{
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records
2026-09-01 16:36 [PATCH 0/3] perf: Suppress redundant ITRACE start records for Arm SPE and CoreSight Leo Yan
2026-09-01 16:36 ` [PATCH 1/3] perf/core: Export perf_event_itrace_started() Leo Yan
@ 2026-09-01 16:36 ` Leo Yan
2026-09-01 16:47 ` sashiko-bot
2026-09-01 16:36 ` [PATCH 3/3] coresight: perf: Suppress " Leo Yan
2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-01 16:36 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Suzuki K Poulose,
Mark Rutland, Adrian Hunter, James Clark, Mike Leach, Tamas Petz,
Tamas Zsoldos
Cc: linux-perf-users, linux-kernel, linux-arm-kernel, coresight,
Leo Yan
PERF_RECORD_ITRACE_START establishes the initial thread context at the
beginning of a trace. Afterwards, decoders track the thread context using
context packets or recorded sched_switch events.
Call perf_event_itrace_started() when event starts to prevent perf core
from emitting redundant PERF_RECORD_ITRACE_START records on later
schedule-ins.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
drivers/perf/arm_spe_pmu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index b70f3fedf0282baba1395ce1116272ec5f961ea8..40314ef8b731e1272e02783a9e6dc7d92ec47139 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -890,6 +890,8 @@ static void arm_spe_pmu_start(struct perf_event *event, int flags)
return;
}
+ perf_event_itrace_started(event);
+
reg = arm_spe_event_to_pmsfcr(event);
write_sysreg_s(reg, SYS_PMSFCR_EL1);
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] coresight: perf: Suppress ITRACE start records
2026-09-01 16:36 [PATCH 0/3] perf: Suppress redundant ITRACE start records for Arm SPE and CoreSight Leo Yan
2026-09-01 16:36 ` [PATCH 1/3] perf/core: Export perf_event_itrace_started() Leo Yan
2026-09-01 16:36 ` [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records Leo Yan
@ 2026-09-01 16:36 ` Leo Yan
2026-09-01 16:45 ` sashiko-bot
2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-01 16:36 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Suzuki K Poulose,
Mark Rutland, Adrian Hunter, James Clark, Mike Leach, Tamas Petz,
Tamas Zsoldos
Cc: linux-perf-users, linux-kernel, linux-arm-kernel, coresight,
Leo Yan
PERF_RECORD_ITRACE_START establishes the initial thread context at the
beginning of a trace. Afterwards, decoders track the thread context using
context packets.
Call perf_event_itrace_started() after successfully starting the event
to prevent perf core from emitting redundant PERF_RECORD_ITRACE_START
records when the event is scheduled in again.
When per-thread mode traces multiple child threads, tooling should
enable context ID tracing instead to identify each thread.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 09b21a711a8764ea429d712890265c84648e889e..80502e8b084074980000a039e73e1a164940011d 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -613,6 +613,8 @@ static void etm_event_start(struct perf_event *event, int flags)
perf_report_aux_output_id(event, hw_id);
}
+ perf_event_itrace_started(event);
+
out:
/* Tell the perf core the event is alive */
event->hw.state = 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] coresight: perf: Suppress ITRACE start records
2026-09-01 16:36 ` [PATCH 3/3] coresight: perf: Suppress " Leo Yan
@ 2026-09-01 16:45 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-09-01 16:45 UTC (permalink / raw)
To: Leo Yan; +Cc: linux-perf-users
> PERF_RECORD_ITRACE_START establishes the initial thread context at the
> beginning of a trace. Afterwards, decoders track the thread context using
> context packets.
>
> Call perf_event_itrace_started() after successfully starting the event
> to prevent perf core from emitting redundant PERF_RECORD_ITRACE_START
> records when the event is scheduled in again.
>
> When per-thread mode traces multiple child threads, tooling should
> enable context ID tracing instead to identify each thread.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-perf_suppress_itrace_start_records-v1-0-c4fbc6860859@arm.com?part=3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records
2026-09-01 16:36 ` [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records Leo Yan
@ 2026-09-01 16:47 ` sashiko-bot
2026-09-02 16:39 ` Leo Yan
0 siblings, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-09-01 16:47 UTC (permalink / raw)
To: Leo Yan; +Cc: linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ITRACE_START records are not suppressed for inherited events due to a child/parent event state mismatch.
--
commit 0683c3b2471a719bb066f5dd9a93d7a7f192399a
Author: Leo Yan <leo.yan@arm.com>
perf: arm_spe: Suppress redundant ITRACE start records
This commit calls perf_event_itrace_started() at the start of an event to
prevent the perf core from emitting redundant PERF_RECORD_ITRACE_START
records on subsequent schedule-ins.
> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
> index b70f3fedf0282..40314ef8b731e 100644
> --- a/drivers/perf/arm_spe_pmu.c
> +++ b/drivers/perf/arm_spe_pmu.c
> @@ -890,6 +890,8 @@ static void arm_spe_pmu_start(struct perf_event *event, int flags)
> return;
> }
>
> + perf_event_itrace_started(event);
> +
[Severity: Medium]
Does this correctly suppress redundant records for inherited events?
The core event scheduling path in perf_log_itrace_start() internally resolves
to event->parent before checking for the PERF_ATTACH_ITRACE flag.
Since perf_event_itrace_started() only mutates the local child event's
attach_state, the parent event's flag remains permanently unset.
Won't this cause the perf core to continue emitting redundant ITRACE_START
records on every subsequent schedule-in for inherited events, negating the
intended fix?
> reg = arm_spe_event_to_pmsfcr(event);
> write_sysreg_s(reg, SYS_PMSFCR_EL1);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-perf_suppress_itrace_start_records-v1-0-c4fbc6860859@arm.com?part=2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] perf/core: Export perf_event_itrace_started()
2026-09-01 16:36 ` [PATCH 1/3] perf/core: Export perf_event_itrace_started() Leo Yan
@ 2026-09-01 16:48 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-09-01 16:48 UTC (permalink / raw)
To: Leo Yan; +Cc: linux-perf-users
> Since Arm SPE and CoreSight drivers can be built as modules, export
> perf_event_itrace_started() so that it can be used by these modules.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-perf_suppress_itrace_start_records-v1-0-c4fbc6860859@arm.com?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records
2026-09-01 16:47 ` sashiko-bot
@ 2026-09-02 16:39 ` Leo Yan
0 siblings, 0 replies; 8+ messages in thread
From: Leo Yan @ 2026-09-02 16:39 UTC (permalink / raw)
To: sashiko-reviews; +Cc: linux-perf-users
On Tue, Sep 01, 2026 at 04:47:04PM +0000, sashiko-bot@kernel.org wrote:
[...]
> > @@ -890,6 +890,8 @@ static void arm_spe_pmu_start(struct perf_event *event, int flags)
> > return;
> > }
> >
> > + perf_event_itrace_started(event);
> > +
>
> [Severity: Medium]
> Does this correctly suppress redundant records for inherited events?
>
> The core event scheduling path in perf_log_itrace_start() internally resolves
> to event->parent before checking for the PERF_ATTACH_ITRACE flag.
>
> Since perf_event_itrace_started() only mutates the local child event's
> attach_state, the parent event's flag remains permanently unset.
>
> Won't this cause the perf core to continue emitting redundant ITRACE_START
> records on every subsequent schedule-in for inherited events, negating the
> intended fix?
This would be an issue in the event core layer and should be addressed
separately. I will send a separate patch to fix it.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-02 16:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 16:36 [PATCH 0/3] perf: Suppress redundant ITRACE start records for Arm SPE and CoreSight Leo Yan
2026-09-01 16:36 ` [PATCH 1/3] perf/core: Export perf_event_itrace_started() Leo Yan
2026-09-01 16:48 ` sashiko-bot
2026-09-01 16:36 ` [PATCH 2/3] perf: arm_spe: Suppress redundant ITRACE start records Leo Yan
2026-09-01 16:47 ` sashiko-bot
2026-09-02 16:39 ` Leo Yan
2026-09-01 16:36 ` [PATCH 3/3] coresight: perf: Suppress " Leo Yan
2026-09-01 16:45 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox