On Wed, Nov 25, 2026 at 06:56:06AM +0000, Kepplinger-Novakovic Martin wrote:
...
> The 2 hangs differ only in 1 line! The last line here "dcss"
> was only printed in 1 of the 2. Other than that, they are identical up to the
> return of drm_display_helper_module_init:
>
> [ 7.328547] calling arm_smmu_init+0x0/0x6c @ 1
> [ 7.328935] initcall arm_smmu_init+0x0/0x6c returned 0 after 377 usecs
> [ 7.328948] calling arm_smmu_driver_init+0x0/0x2c @ 1
> [ 7.329065] initcall arm_smmu_driver_init+0x0/0x2c returned 0 after 108 usecs
> [ 7.329077] calling drm_core_init+0x0/0xbc @ 1
> [ 7.329131] initcall drm_core_init+0x0/0xbc returned 0 after 42 usecs
> [ 7.329143] calling drm_display_helper_module_init+0x0/0x8 @ 1
> [ 7.329155] initcall drm_display_helper_module_init+0x0/0x8 returned 0 after 0 usecs
> [ 7.329167] calling dcss_platform_driver_init+0x0/0x38 @ 1
CoreSight initialization appears to have completed. One possibility is
that runtime PM then disabled a clock or power domain that a later
driver needs.
Seems to me, dcss_platform_driver_init() is suspicious. If it is
dependent on clocks used by CoreSight, this can be the cause.
> > Could you confirm what exactly CoreSight modules have been enabled?
>
> of course:
>
> CONFIG_CORESIGHT=y
> CONFIG_CORESIGHT_LINKS_AND_SINKS=y
> CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y
> CONFIG_CORESIGHT_SOURCE_ETM4X=y
Thanks, that matches the logs.
> > As separate diagnostic tests, could you try clk_ignore_unused and
> > nohlt, one at a time, to see whether unused-clock disabling or
> > CPU idle affects reproduction?
>
> I'll do that as a follow up later.
AI reminds on clk_ignore_unused: "if dcss_platform_driver_init() itself
hangs, the kernel never reaches the clock cleanup. Runtime PM can
disable a clock before that point. I’d first check whether the DCSS
probe reaches its first write to DCSS_BLKCTL_CONTROL0 and whether the
required clocks are enabled at that point." It makes sense to me.
Thanks,
Leo
On 24/11/2026 20:41, Adrian Hunter wrote:
> On 05/11/2026 13:45, James Clark wrote:
>> find_snapshot() isn't implemented for Coresight, so when a wrap occurs
>> we only save from offset 0 to current head, modulo buffer size, rather
>> than capturing the whole buffer. Coresight drivers currently use a
>> monotonic head pointer even in snapshot mode, which gives a lot more
>> information for taking snapshots than a wrapped pointer. It means we
>> don't need to search for data at the end of the buffer to guess if a
>> wrap has occurred, and we can go back to saving partial buffers after a
>> wrap by checking if the next size to take is less than the buffer
>> size.
>>
>> The drivers will always be able to generate a monotonic head because
>> TRBE has a bytes written counter, so even if we stop generating an AUX
>> record on every overflow, we can check if the counter indicated an
>> overwrite and offset head by a whole buffer size if it wrapped. This
>> forces userspace to read the whole buffer rather than between last and
>> current head. ETR and other sinks use software double buffering, so can
>> continue as they are.
>>
>> Add auxtrace_record__monotonic_find_snapshot() and use it for Coresight.
>> A monotonic head can't be auto-detected in the default find_snapshot()
>> by checking if head > buffer size, because before the first wrap a
>> monotonic head looks the same as a wrapped one. The search would then
>> falsely detect a wrap when head is near the end of the buffer, and the
>> wrapped pointer fixup moves 'old' and 'head' a whole buffer ahead of the
>> driver's head. With a wrapped head that doesn't matter because only the
>> offset within the buffer is used, but with a monotonic head the next
>> snapshot would either save already saved data again or drop up to a
>> buffer's worth of new data.
>>
>> Reviewed-by: Leo Yan <leo.yan(a)arm.com>
>> Tested-by: Leo Yan <leo.yan(a)arm.com>
>> Signed-off-by: James Clark <james.clark(a)linaro.org>
>
> Reviewed-by: Adrian Hunter <adrian.hunter(a)intel.com>
>
Thanks!
This series depends on:
https://lore.kernel.org/linux-perf-users/20261030-perf_cs_etm_fix_non_taken…
Fix a few issues with per-thread mode:
- On nVHE, everything looks like guest trace instead of host
- Tracing multiple threads didn't really work
After adding a tests for those, it turns out there were some snapshot
bugs not picked up by the other snapshot tests. That showed that the
different snapshot searches for Intel BTS and Arm SPE were inconsistent
and I think all tracers can benefit from using the same pointer fixup
logic, so that gets refactored into the common auxtrace.c. Then SPE can
just share the Intel BTS search as it was obviously copied from it
originally. IntelPT keeps the more advanced duplicate data search, but
in the future that could probably be made the common one and all tracers
would benefit from using it (except maybe BTS if it always has a very
small buffer, but I doubt the overhead of the duplicate search would be
an issue). For now this is more of a refactor rather than behavioral
change so don't do that yet.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v4:
- Change test snapshot size to 128K for 64K machines
- Put patchset depencency in cover letter text
- Link to v3: https://patch.msgid.link/20261102-james-cs-unformatted-per-thread-fix-v3-0-…
Changes in v3:
- Keep the find_snapshot() callback instead of adding
snapshot_has_wrapped() and monotonic_snapshot_head boolean (Adrian)
- Add auxtrace_record__default_find_snapshot() for the simple search for
BTS and SPE (Adrian)
- Add auxtrace_record__snapshot_fixup() for any snapshot search
implementation to use to update the pointers (Adrian)
- Reword UINT64_MAX timestamp comment (Leo)
- Fix disassembly test after rebasing onto exception sample fixes
- Only take 'perf_guest' into account if there is no PIDFMT_CTXTID2
- Improve decoding of old files by hard coding queue 0 for per-thread
- Link to v2: https://patch.msgid.link/20260821-james-cs-unformatted-per-thread-fix-v2-0-…
Changes in v2:
- Remove stale "may be reset to -1 in per-thread mode" comment
- Set CPU when queueing auxtrace fragments otherwise
auxtrace_queues__add_event() overwrites the queue's CPU
- Link to v1: https://patch.msgid.link/20260811-james-cs-unformatted-per-thread-fix-v1-0-…
---
James Clark (19):
perf cs-etm: Fix nVHE per-thread decoding
perf cs-etm: Warn for invalid timestamp option
perf cs-etm: Turn on context packet timestamps in per-thread mode
perf cs-etm: Use per-CPU queues for per-thread mode
perf test: cs-etm: Increase window size in disassembly test
perf cs-etm: Don't drop previous target for kernel samples
perf python: Expose sample instruction length
perf cs-etm: Use instruction length in disassembly script
perf cs-etm: Increase default timestamp generation period
perf auxtrace: Turn Intel BTS snapshot search into a generic one
perf arm-spe: Use generic snapshot search
perf auxtrace: intel-pt: Use common snapshot pointer fixup
perf cs-etm: Queue partial AUX records
perf cs-etm: Don't print missing buffers in snapshot mode
perf auxtrace: cs-etm: Capture wrapped snapshots
perf test: Allow infinite named_thread loops
perf test: cs-etm: Add test for per-thread mode
perf test: cs-etm: Test multiple per-thread threads
perf test: cs-etm: Increase snapshot size
tools/perf/Documentation/perf-test.txt | 2 +-
tools/perf/arch/arm/util/cs-etm.c | 34 ++++-
tools/perf/arch/arm64/util/arm-spe.c | 147 +--------------------
tools/perf/arch/x86/util/intel-bts.c | 115 +---------------
tools/perf/arch/x86/util/intel-pt.c | 21 +--
tools/perf/python/arm-cs-trace-disasm.py | 22 +--
tools/perf/python/perf.pyi | 1 +
.../perf/tests/shell/coresight/per-thread-multi.sh | 76 +++++++++++
tools/perf/tests/shell/coresight/per-thread.sh | 48 +++++++
.../perf/tests/shell/coresight/raw_dump_stress.sh | 5 -
.../shell/coresight/test_arm_coresight_disasm.sh | 8 +-
tools/perf/tests/workloads/named_threads.c | 7 +-
tools/perf/util/auxtrace.c | 145 +++++++++++++++++++-
tools/perf/util/auxtrace.h | 18 +++
tools/perf/util/cs-etm.c | 113 +++++++++++-----
tools/perf/util/python.c | 1 +
16 files changed, 420 insertions(+), 343 deletions(-)
---
base-commit: 28ef93607ad52acc8f8be25199711153ba11a0c2
change-id: 20260605-james-cs-unformatted-per-thread-fix-50e723aa7f0e
prerequisite-message-id: <20261030-perf_cs_etm_fix_non_taken-v3-0-7629b52ab047(a)arm.com>
prerequisite-patch-id: 4ef889ad751e344ae47c1d75a2a2e6cb2eadf6e1
prerequisite-patch-id: 636b39730334cbc5a76642c070e704ffe178e7be
prerequisite-patch-id: fb58f6daebdf5a194f8aa56ccc4022f932a5a6e5
prerequisite-patch-id: d240c10c6824f8ae6c3f10a1da01226a957f05fb
prerequisite-patch-id: 17b291db261e32dcb0d6f1ab2ed0adb7e0411813
prerequisite-patch-id: 45ae1d523c9e5c8c573309f1dab107a598f3d4f8
prerequisite-patch-id: 39a3eb25b3a45f4481760c25fa270773bcfd94f5
prerequisite-patch-id: 5723a15636c2a28ec40eb6b5c9836d162e971786
prerequisite-patch-id: d18054b586fc38bc832ead185e8c1fbb0ce46f39
prerequisite-patch-id: 6735b192189d7945613458abce3da871cb79b35d
prerequisite-patch-id: 387cb2c6181bef8f45a8fb167e8ef86e4a54ff69
prerequisite-patch-id: 50243a8d1739141aa24aa371a8452d4d2d078a99
prerequisite-patch-id: 2ae6f1e7707ba0c71a0678331b02d738fb25cb3c
prerequisite-patch-id: 1fa0a90cfbc904c4429c1427409125ac44b27aed
Best regards,
--
James Clark <james.clark(a)linaro.org>
Perf throttles a group by calling each event's PMU stop callback with
flags set to zero. On a CPU with a trace path, ETM stops tracing and
leaves the AUX transaction open because PERF_EF_UPDATE is clear. When
perf unthrottles the event, perf_aux_output_begin() warns because
aux_nest is still set.
[ 181.161897] ------------[ cut here ]------------
[ 181.161906] WARNING: kernel/events/ring_buffer.c:415 at perf_aux_output_begin+0x1dc/0x1f0, CPU#0:2
[ 181.234120] arm-scmi arm-scmi.1.auto: timed out in resp(caller: do_xfer+0x1a0/0x558)
[ 181.234223] cpufreq: __target_index: Failed to change cpu frequency: -110
[ 181.286675] Modules linked in: panfrost tda9950 hdlcd tda998x drm_shmem_helper drm_client_lib cect
[ 181.314139] CPU: 0 UID: 0 PID: 352 Comm: perf Not tainted 7.1.0-rc1-00058-gdca922e019dd-dirty #11
[ 181.323915] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, B5
[ 181.334732] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 181.341721] pc : perf_aux_output_begin+0x1dc/0x1f0
[ 181.346547] lr : perf_aux_output_begin+0x9c/0x1f0
[ 181.351280] sp : ffff800080003be0
[ 181.354606] x29: ffff800080003be0 x28: ffff0008023fc000 x27: ffff4b45d287f000
[ 181.361789] x26: ffff0009764787a8 x25: 0000000000000000 x24: ffff00080dc99710
[ 181.368970] x23: ffffb4c334553000 x22: 0000000000000001 x21: ffff00080dc99710
[ 181.376151] x20: ffff0009764787a8 x19: ffff000801cc6000 x18: 00000000ffffffff
[ 181.383332] x17: 0000000000000000 x16: ffffb4c3a118c998 x15: 0000000000000000
[ 181.390512] x14: 00003d0900000000 x13: 00000001ffff006e x12: 696765625f747570
[ 181.397692] x11: ffffb4c3a52758d8 x10: 0000000000000108 x9 : ffffb4c3a117f620
[ 181.404873] x8 : ffff800080003a58 x7 : ffff000808de4000 x6 : 00000000000fffff
[ 181.412053] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[ 181.419232] x2 : 0000000000000007 x1 : 0000000000000000 x0 : 0000000000000007
[ 181.426411] Call trace:
[ 181.428868] perf_aux_output_begin+0x1dc/0x1f0 (P)
[ 181.433692] etm_event_start+0xdc/0x290 [coresight]
[ 181.438665] perf_event_unthrottle+0x70/0xa8
[ 181.442964] perf_event_unthrottle_group+0x40/0x170
[ 181.447871] perf_adjust_freq_unthr_events+0x178/0x1a8
[ 181.453038] perf_adjust_freq_unthr_context+0x74/0xf8
[ 181.458120] perf_event_task_tick+0xa8/0x290
[ 181.462418] sched_tick+0x144/0x2c8
[ 181.465937] update_process_times+0xc0/0x198
End the AUX transaction with size zero on a throttling stop so
unthrottling can acquire a fresh handle. Collect trace data only when
PERF_EF_UPDATE is set.
Check AUX handle ownership before updating the buffer or ending AUX
output. Drop the post-update check because the full stop runs with
local IRQs disabled, which prevents the TRBE IRQ from closing the
handle during the stop.
This patch is limited to fixing the event throttling case. Other issues,
such as CPUs without a trace path and pending TRBE IRQs during sink
teardown, will be addressed by the following patch series [1][2].
[1] https://lore.kernel.org/linux-arm-kernel/20260915-arm_cs_support_aux_sample…
[2] https://lore.kernel.org/linux-arm-kernel/20261016-trbe_enable_disable_irq_h…
Fixes: 9734e25fbf5a ("perf: Fix the throttle logic for a group")
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
drivers/hwtracing/coresight/coresight-etm-perf.c | 34 +++++++-----------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 909bfd5960331d44547a028fde336f7819488a1a..e506116723c4ed723d66bc721021718b5d176117 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -698,7 +698,7 @@ static void etm_event_pause(struct coresight_path *path,
static void etm_event_stop(struct perf_event *event, int mode)
{
int cpu = smp_processor_id();
- unsigned long size;
+ unsigned long size = 0;
struct coresight_device *source, *sink;
struct etm_ctxt *ctxt = this_cpu_ptr(&etm_ctxt);
struct perf_output_handle *handle = &ctxt->handle;
@@ -757,33 +757,19 @@ static void etm_event_stop(struct perf_event *event, int mode)
* handle due to lack of buffer space), we don't
* have to do anything here.
*/
- if (handle->event && (mode & PERF_EF_UPDATE)) {
- if (WARN_ON_ONCE(handle->event != event))
- return;
+ if (!handle->event || WARN_ON_ONCE(handle->event != event))
+ goto out;
+ if (mode & PERF_EF_UPDATE) {
/* update trace information */
- if (!sink_ops(sink)->update_buffer)
- return;
-
- size = sink_ops(sink)->update_buffer(sink, handle,
- event_data->snk_config);
- /*
- * Make sure the handle is still valid as the
- * sink could have closed it from an IRQ.
- * The sink driver must handle the race with
- * update_buffer() and IRQ. Thus either we
- * should get a valid handle and valid size
- * (which may be 0).
- *
- * But we should never get a non-zero size with
- * an invalid handle.
- */
- if (READ_ONCE(handle->event))
- perf_aux_output_end(handle, size);
- else
- WARN_ON(size);
+ if (sink_ops(sink)->update_buffer)
+ size = sink_ops(sink)->update_buffer(sink, handle,
+ event_data->snk_config);
}
+ perf_aux_output_end(handle, size);
+
+out:
/* Disabling the path make its elements available to other sessions */
coresight_disable_path(path);
}
---
base-commit: 8e3ac058be1b613aeabcb7ce18c142e4603cc5dd
change-id: 20261124-arm_cs_fix_throttling_oops-140053eb0883
Best regards,
--
Leo Yan <leo.yan(a)arm.com>
Hi Song,
On Mon, Nov 23, 2026 at 11:07:37AM -0800, Song Liu wrote:
> Hi Leo,
>
> On Tue, Sep 15, 2026 at 8:49 AM Leo Yan <leo.yan(a)arm.com> wrote:
> >
> > Since commit 9734e25fbf5a ("perf: Fix the throttle logic for a
> > group"), the perf core stops every event in a throttled group by calling
> > the PMU stop callback with flags set to zero:
> >
> > perf_event_throttle()
> > `> event->pmu->stop(event, 0)
> >
> > The ETM perf stop callback only ends the AUX output handle when
> > PERF_EF_UPDATE was set. For throttling with mode is zero, it skips to
> > end the AUX handle. When the event is later unthrottled and ETM tracing
> > is started again, perf_aux_output_begin() sees the perf handle is nest
> > enabled and triggers a warning:
>
> While testing this patch, we found a crash:
> [20123.449766] Call trace:
> [20123.454671] arm_trbe_irq_handler+0x58/0x4d8 [coresight_trbe] (P)
> [20123.466920] handle_percpu_devid_irq+0x80/0x1b0
> [20123.476029] generic_handle_domain_irq+0x3c/0x80
> [20123.485308] gic_handle_irq+0x174/0x328
...
> LLM suggests the following change should fix it. Does this make
> sense to you?
Yes, the change below looks reasonable to me overall. I have a patch
series to refactor the TRBE driver [1], and patches 05 and 09 make
similar changes.
Do you mind to test the series (or apply patches 01 ~ 09) to check
if issue can be fixed?
Thanks,
Leo
[1] https://lore.kernel.org/linux-arm-kernel/20261016-trbe_enable_disable_irq_h…
On Thu, Nov 12, 2026 at 11:41:18PM -0800, Amir Ayupov wrote:
[...]
> pmu_pulse (coresight-only)
> ----------------------------------------------
>
> The first attempt was to try to avoid perf/core entirely, and extend
> a coresight config with pulsing ETE external output on every cycle
> while tracing is enabled [1]. This way, pause event on TRCEXTOUTn
> ends the window after exacly N traced cycles. The use of ETE external
> output is pure coincidence, just a way to count cycles only while
> tracing is enabled.
>
> However, the review has raised that the config is not self-contained
> and requires a lot of checks to only enable it on capable HW:
> - needs a helper in the arm64 PMUv3 header and a move of PMU
> definitions - needs arm64 maintainer's approval;
> - only works on ETE whose PMU counts TRCEXTOUTn,
> - the window is always measured in traced cycles;
> - is restricted to ETM, doesn't help Intel PT,
> - the further it is from a pure config change, the less understanding
> I have to support the patch series further.
>
> I decided to abandon that approach and ask for a better/more general
> solution, hence this RFC.
I saw you have sent CoreSight and PMU pulse v6, I will review it.
It is a good improvement for me.
> Option 3: cross-event "arming" (attr.aux_pause_armed)
> ---------------------------------------------------------------------
>
> This extends aux-action with a new bit (aux_pause_armed):
> - aux pause event period is set in an overflow of aux resume in group,
> - restarts from the full period,
> - on overflow, pauses aux tracing:
>
> This is the most flexible and general solution:
> ```
> # resume every 10M cycles, trace 5000 cycles
> -e '{cs_etm/aux-action=start-paused/,
> cycles/aux-action=resume,period=10000000/,
> cycles/aux-action=pause-armed,period=5000,call-graph=fp/}'
>
> # resume on page faults, trace 100k instructions
> -e '{intel_pt/aux-action=start-paused/,
> page-faults/aux-action=resume/,
> instructions/aux-action=pause-armed,period=100000/}'
> ```
I am just wandering if we can extend a bit "aux-action" syntax to
support delta value, something like:
-e '{cs_etm/aux-action=start-paused/,
cycles/aux-action=resume,period=10000000/,
cycles/aux-action=pause,period=+5000,call-graph=fp/}'
The + symbol indicates that the pause event occurs 5,000 cycles after
the resume event.
> Cons:
> 1. the core has to keep a disarmed event stopped across group
> scheduling, throttling, ioc_period, power mgmt.
> 2. rearming happens in the overflow handler (in NMI/IRQ).
> 3. Software pause events are not supported.
Why here software pause event cannot be supported?
> Question
> ---------
>
> Does it sound reasonable for perf to support this, or it's better
> to pursue pt/coresight-specific solutions? In the end, my use case
> is about tracing.
I think you are asking perf core maintainers to explore a proper way to
move forward. If no feedback, it is good to send RFC series to
demonstrate idea if you have a preference.
> If yes, which option is preferable?
> - Option 1 with restoring first period behavior that was already there,
> - option 2 as cleaner fix,
> - option 3 as completely general but with more core state to track,
> - something else?
Seems to me, if we extend a bit with "+" syntax, this can be general
enough to benefit all AUX trace. And we don't need to introduce extra
new interface.
Thanks,
Leo
On Thu, Nov 19, 2026 at 01:00:03PM -0800, Yabin Cui wrote:
[...]
> Hi Leo, Dev,
>
> I tested on an arm64 Android Pixel device (4 KiB pages, 12 GiB RAM +
> 6 GiB zram, TRBE & SPE) using an Android kernel patched locally to match
> v7.4-rc3's rb_alloc_aux() / __alloc_pages_slowpath() behavior
> (526d945ad9c0, 669872181549, 53a9b4646f67, 0e05a469c294).
>
> v7.4-rc3 alone still causes heavy PSI and compaction/reclaim stalls on
> Android, while patch [1] keeping __GFP_NORETRY fixes it completely.
>
> compact-bench (90/95/99%, 10 runs each = 30 runs, 4 MiB/CPU TRBE AUX,
> 0 allocation failures; system-wide PSI since Android sets
> cgroup_disable=pressure):
>
> Config PSI some(ms) cmp_stall allocstall daemon_wake sp_kswapd_wk
> order-0 297.76 0 0 0 0
> revert 2,578.00 3,957 1,984 17 28
> v7.4-rc3-sim 1,840.29 522 161 14 21
> rc3 + [1] 270.77 0 0 0 0
> rc3 + [1]-noretry 41.78 0 0 0 1
It's good to see no allocation failures and much lower PSI with
rc3 + [1]-noretry.
> Even when order-3 pages are still plentiful (e.g. 95%, where order-3
> never failed and cmp_stall/allocstall were 0), v7.4-rc3-sim still
> woke kswapd/kcompactd for failed orders 4..9 on 10/10 runs (7
> kcompactd wakes), producing 895.48 ms PSI vs. 2.87 ms with
> [1]-noretry.
>
> When order-3 does run out (99% Run 1), v7.4-rc3-sim bypasses
> 0e05a469c294 and hits 521 direct compactions / 161 direct reclaims
> (Runs 2..10 dropped to 1/0 by reusing freed AUX pages; that only
> helps when traces run back-to-back in a short window, which doesn't
> match our use case on Android).
I see that v7.4-rc3-sim (or with equivalent mainline kernel) can still
show increased PSI.
> Under a realistic Android fragmentation test (incompressible zram
> pages, unmovable pages, re-fragmented between runs), v7.4-rc3-sim also
> triggered an lmkd kill (TRBE) and direct compaction/reclaim stalls
> (SPE), all 0 with [1]-noretry.
>
> When unfragmented, [1]-noretry still allocates 100% order-9 (2 MiB)
> chunks for both TRBE and SPE.
>
> So I agree with Dev to drop __GFP_RETRY_MAYFAIL and keep __GFP_NORETRY
> (0 allocation failures and lower PSI). Please proceed with v2 of [1]
> keeping __GFP_NORETRY (and avoid backporting 526d945ad9c0 to
> stable without it).
I don't expect 526d945ad9c0 to be backported to stable kernels, as it
has no Fixes tag. We just need to ensure that mainline and future LTS
kernels (and ACK) avoid PSI regressions..
I'll send v2 with keeping __GFP_NORETRY as you and Dev suggested.
Thanks a lot, Yabin and Dev!
Leo
This series adds AUX sampling support to Arm CoreSight. A PMU sample can
carry a window of recent AUX trace, which perf generates callchain and
branch stack for the sampled thread. This provides execution history for
context-based profiling.
The series can be divided into four parts:
1. Patches 01 ~ 03 for event core:
The perf event core changes warn on non-positive AUX snapshot
returns before checking alignment padding. Space for a non-zero AUX
payload has already been reserved, so a zero return leaves that
payload unwritten. CoreSight fills unavailable trace with zeros and
returns the requested size.
It also prevents AUX sampling and pause/resume from nesting through
an NMI. A driver guard alone can leave perf's pause state
(aux_paused) inconsistent with the hardware state. The event core
ensures only one AUX callback is exclusively invoked.
Export the output copy helpers so CoreSight can fill sample payloads
when the driver is built as a module.
2. Patches 04 ~ 09 for ETM perf:
The ETM perf changes separate the lifetime of the published CoreSight
context from that of the AUX output handle.
Centralize buffer updates, and end AUX output when throttling stops
an event without PERF_EF_UPDATE so a later restart can acquire a
fresh handle.
Make hardware-state transitions reflect completed operations.
3. Patches 10 ~ 13 for TRBE driver:
TRBE snapshot buffers need padding to meet the CPU's alignment and
wrap constraints. Use circular buffer mode for overwrite snapshots,
retaining Fill mode on CPUs that require the write out-of-range
workaround.
TRBE faults can still raise interrupts in circular mode. Track when
the sink is handling an interrupt so an AUX sampling NMI can skip a
snapshot while the interrupted handler is updating the buffer. Make
repeated sink disable safe for deferred cleanup after a snapshot
failure.
4. Patches 14 ~ 25 for AUX sampling and decoding:
Shared atomic STOP and AUX action bits prevent an NMI stop from
tearing down the context while pause, resume or snapshot accesses it.
The AUX operation finishes and then completes the deferred stop,
publishing the stopped state only after hardware teardown.
Add snapshot_aux() to the CoreSight driver to pause the source, update
the sink buffer, disable the path, copy the recent trace into the PMU
sample, and then re-enable the path and resume the source.
Patch 17 fixes history collection for zero-IP PMU samples. Perf clears
the IP when a user-only sampling interrupt skids into the kernel, but
the timestamp and TID remain valid for matching the trace history.
In perf, decode each embedded payload as an independent trace window,
selecting the decoder with the sampled CPU and using the sample's
PID/TID and traced context IDs to attribute history to the sampled
thread. Refactor common timeless decoding and history collection, and
drain pending OpenCSD output so buffered history is not lost.
Attach reconstructed callchains and branch stacks to the original PMU
samples, preserving histories already present in the samples. Add a
test, and document the recording and decoding workflow and its
limitations.
The initial support targets unformatted trace from per-CPU sinks such as
TRBE. Shared formatted sinks such as ETR can mix trace from multiple CPUs,
consuming the limited sample window with execution unrelated to the
sampled thread.
This series is based on Amir's series "perf: Add CoreSight branch
history to existing samples" [1] for perf tool's branch / callchain
generating.
[1] https://lore.kernel.org/linux-perf-users/cover.1787005265.git.aaupov@fb.com/
Signed-off-by: Leo Yan <leo.yan(a)arm.com>
---
Leo Yan (25):
perf/core: Reject non-positive AUX snapshot sizes
perf/core: Prevent AUX sampling from racing with pause/resume
perf/core: Export output copy helpers for CoreSight
coresight: perf: End AUX output when an event is throttled
coresight: perf: Extract AUX buffer update helper
coresight: perf: Simplify flow for CPUs without a path
coresight: perf: Validate the live context through its path
coresight: perf: Validate context before resuming trace
coresight: perf: Improve hardware state transitions
coresight: trbe: Pad snapshot buffers
coresight: trbe: Use circular buffer mode for snapshots
coresight: trbe: Track per-CPU sink interrupt handling
coresight: trbe: Handle an already disabled sink
coresight: perf: Look up the trace path in etm_event_pause()
coresight: perf: Serialize AUX pause and resume with event stops
coresight: perf: Support AUX sampling with per-CPU sinks
perf cs-etm: Allow history collection for samples with zero IP
perf cs-etm: Unify timeless buffer decoding
perf cs-etm: Propagate errors from trace queue flushing
perf cs-etm: Drain pending packets before finishing trace blocks
perf cs-etm: Complete packet draining with end of trace
perf cs-etm: Centralize sample history collection
perf cs-etm: Decode AUX samples into callchains and branch stacks
perf test: Add CoreSight AUX sample decoding test
Documentation: coresight: Document AUX sample decoding
Documentation/trace/coresight/coresight-perf.rst | 39 ++
drivers/hwtracing/coresight/coresight-etm-perf.c | 396 +++++++++++++-----
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 +
drivers/hwtracing/coresight/coresight-trbe.c | 122 ++++--
include/linux/coresight.h | 2 +
kernel/events/core.c | 26 +-
kernel/events/ring_buffer.c | 2 +
tools/perf/arch/arm/util/cs-etm.c | 6 +
tools/perf/tests/shell/coresight/aux_sample.sh | 189 +++++++++
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 39 ++
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 +
tools/perf/util/cs-etm.c | 491 ++++++++++++++++-------
12 files changed, 1040 insertions(+), 281 deletions(-)
---
base-commit: 134e1295eedfc9a3c6e4e63d8ef45dc63749449b
change-id: 20260826-arm_cs_support_aux_sample-275664545588
Best regards,
--
Leo Yan <leo.yan(a)arm.com>