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>
Hi Vlad,
On Fri, Nov 20, 2026 at 09:27:39AM -0800, Vlad Poenaru wrote:
> On 16/10/2026 14:46, James Clark wrote:
> > Reviewed-by: James Clark <james.clark(a)linaro.org>
>
> Hi Suzuki, Mike, James, Leo,
>
> Could this go in alone as a v7.4 fix, with Cc: stable(a)vger.kernel.org?
> It does not depend on the rest of the series and applies cleanly to
> v7.4-rc3.
I agree that this patch can be an independent fix. Since it has a stable
tag, it will be automatically backported to stable kernels once it is
merged into mainline.
@Suzuki, how about you think? I confirmed it can be applied clearly on
coresight-next branch.
Thanks,
Leo
On Wed, Nov 18, 2026 at 08:58:26PM +0200, Igor Velkov wrote:
> On Wed, Nov 18, 2026 at 10:49:17AM +0000, Leo Yan wrote:
> > 1) If idle_cpu(cpu) == 0, sample the CPU directly.
> > 2) If idle_cpu(cpu) == 1, follow the existing flow to request
> > power-up before sampling.
>
> I tried step 2 on RK3399 (Cortex-A53 + A72, cpuidle with core
> powerdown), following debug_read_regs() on a running system:
>
> - Idle A53 (EDPRSR.PU = 0): the EDOSLAR write raises an SError on the
> reading CPU. COREPURQ brings the core up only for a moment; with
> COREPURQ | CORENPDRQ it is off again within 10 ms, and the write
> still faults.
> - Idle A72 (PU = 1, R = 1): the same SError on the EDOSLAR write.
> - Busy CPUs (idle_cpu() == 0) on both clusters: no errors, full PC.
>
> So on this SoC only step 1 is safe.
This is why I suggested 3) in my previous reply. Seems you should skip
sample idle CPUs if COREPURQ/CORENPDRQ are not properly integrated in
the SoC.
Thanks,
Leo
Hi,
On Thu, Nov 19, 2026 at 11:10:50AM +0000, Kepplinger-Novakovic Martin wrote:
> hi Suzuki, Mike and others,
>
> I don't really know the coresight hardware but with CORESIGHT enabled, when I do
> "reboot tests" on imx8mp, I see the kernel hang after (randomly) 200 to 2000 (sometimes
> a hang was seen even later) reboots at *about* the line below. But indeed not exactly
> that line. sometimes it stops 4-7 lines earlier!
Could you enable earlycon together with ignore_loglevel and initcall_debug?
So far, the info is too limited to give any useful hints.
> [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
> [ 0.000000] Linux version 6.18.63-ge-26.10+-ge_bep4-eta-1-00195-gb8bebc692f96 (root@ginzinger) (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot
> -gf002287f) 13.4.0, GNU ld (GNU Binutils) 2.43.1) #41 SMP PREEMPT Thu Nov 12 09:08:03 CET 2026
> [ 0.000000] KASLR disabled due to lack of seed
> [ 0.000000] Machine model: BE-P4 i.MX8MPlus in NDM
> [ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] NODE_DATA(0) allocated [mem 0x7fdb6e80-0x7fdb9b7f]
> [ 0.000000] Zone ranges:
> [ 0.000000] DMA [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] DMA32 empty
> [ 0.000000] Normal empty
> [ 0.000000] Movable zone start for each node
> [ 0.000000] Early memory node ranges
> [ 0.000000] node 0: [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] cma: Reserved 32 MiB at 0x000000007cc00000
> [ 0.000000] psci: probing for conduit method from DT.
> [ 0.000000] psci: PSCIv1.1 detected in firmware.
> [ 0.000000] psci: Using standard PSCI v0.2 function IDs
> [ 0.000000] psci: MIGRATE_INFO_TYPE not supported.
>
> The kernel does not panic. It hangs. The problem goes away and it reboots indefinitely
> when I disable coresight in the config.
Could you confirm what exactly CoreSight modules have been enabled?
> I sometimes need to run an old v5.10-imx based kernel, where I've *not* reproduced
> this hang with coresight enabled.
>
> Was there a regression in mainline or does NXP have a fix in their tree? Have you see
> something like this before?
I am not aware of a CoreSight regression. I cannot comment on NXP
board as I don't have it.
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?
Thanks,
Leo
Concurrent per-thread events results in a WARN on N1SDP which leads to
the realization that per-thread events shouldn't have been sharing sinks
in the first place.
This slips through because different per-thread events will have the
same PID if owned by the same process, and we only check the PID and
nothing else. That results in unexpected WARNs because it looks like we
assumed it couldn't happen (although exclusive PMU rules allow it). But
even if it was supported it would result in trace from the wrong thread
in another event's per-thread buffer, so we should disallow it.
Fix it by determining if sharing can happen at setup time. Then remove
everywhere the same PID checking logic was copy pasted in each sink.
The first three patches fix configuration initialization, AUX cleanup
and topology locking. The remaining patches enforce the sharing rules
and simplify the sink drivers.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v4:
- Count CPU sources in the registered topology and retain each sink's
sharing classification until its last AUX session ends.
- Serialize AUX topology access and provide locked and locking path
release functions.
- Reject unexpected path setup errors while retaining silent skips for
missing ETMs and unreachable sinks.
- Prevent all problematic sharing cases at aux setup rather than at
runtime. (Leo)
- Drop "coresight: tmc-etr: Don't stop Perf cleanup for active sysfs
reads". It was a pre-existing bug and is even more unrelated now with
the new model.
- Remove workqueue rather than fix the lifecycle, its no longer
needed. (Leo)
- Add a getter for the config manager, cscfg_get_state(). (Leo)
- Link to v3: https://lore.kernel.org/r/20260728-james-cs-multiple-per-threads-v3-0-6aee7…
Changes in v3:
- Storing and accessing event owners at runtime causes problems due to
various scenarios of: events (and sibling events) exiting, children
inheriting event FDs, PID reuse, CPU affine events that also have a
target process set but different inherit settings. Fix it by creating
a session ID in etm_setup_aux() and holding the references in it for
the duration of the whole session. (Leo)
- Make the ETR buffer allocator consistent with sink sharing rules by
not doing numeric PID comparisons there either.
- Fix up some Sashiko reports that it sees after interacting with cscfg
and taking extra references to tasks and PIDs.
- Link to v2: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v2-0-10ac7…
Changes in v2:
- Fix inherited events by following event->parent
- Link to v1: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v1-0-d384e…
---
James Clark (10):
coresight: configfs: Don't assume active until cscfg_mgr is set
coresight: etm-perf: Remove workqueue for freeing AUX data
coresight: etm-perf: Serialize AUX topology access
coresight: etm-perf: Reject event if building path fails
coresight: etm-perf: Prevent sink sharing at setup time
coresight: tmc-etr: Reflect new sharing rules in allocator
coresight: tmc-etr: Remove sharing guards from ETR
coresight: tmc-etf: Remove sharing guards from ETF
coresight: etb10: Remove sharing guards from ETB10
coresight: ultrasoc-smb: Remove sharing guards from SMB
drivers/hwtracing/coresight/coresight-core.c | 104 +++++++++++++++--
drivers/hwtracing/coresight/coresight-etb10.c | 28 +----
drivers/hwtracing/coresight/coresight-etm-perf.c | 119 ++++++++++---------
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 -
drivers/hwtracing/coresight/coresight-priv.h | 4 +-
drivers/hwtracing/coresight/coresight-syscfg.c | 11 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 4 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 6 +-
drivers/hwtracing/coresight/coresight-tmc-etf.c | 22 +---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 142 +++++++----------------
drivers/hwtracing/coresight/coresight-tmc.h | 16 +--
drivers/hwtracing/coresight/coresight-trace-id.c | 97 ++++++++++++++--
drivers/hwtracing/coresight/coresight-trace-id.h | 26 +++--
drivers/hwtracing/coresight/ultrasoc-smb.c | 20 +---
drivers/hwtracing/coresight/ultrasoc-smb.h | 3 -
include/linux/coresight.h | 26 ++++-
16 files changed, 346 insertions(+), 284 deletions(-)
---
base-commit: 343cfcbb3ecfdb80aa576a428cfa3b65ad783842
change-id: 20260708-james-cs-multiple-per-threads-ed1d25ed1734
Best regards,
--
James Clark <james.clark(a)linaro.org>