[PATCH v3 0/8] coresight: Prevent per-thread events from sharing a sink

From: James Clark

Date: Tue Jul 28 2026 - 11:43:34 EST


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 everywhere the same PID checking logic was copy pasted. Then the
PIDs can be dropped from a few structs as they are now unused.

Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
---
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-10ac7ac6af0b@xxxxxxxxxx

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-d384e6d477ac@xxxxxxxxxx

---
James Clark (8):
coresight: tmc-etr: Don't stop Perf cleanup for active sysfs reads
coresight: configfs: Don't assume active until cscfg_mgr is set
coresight: etm-perf: Flush workqueue before unloading module
coresight: tmc-etr: Prevent per-thread events from sharing a sink
coresight: tmc-etr: Use session ID for buffer ownership
coresight: tmc-etf: Prevent per-thread events from sharing a sink
coresight: etb10: Prevent per-thread events from sharing a sink
coresight: ultrasoc-smb: Prevent per-thread events from sharing a sink

drivers/hwtracing/coresight/coresight-core.c | 28 +--
drivers/hwtracing/coresight/coresight-etb10.c | 33 ++--
drivers/hwtracing/coresight/coresight-etm-perf.c | 79 ++++++++-
drivers/hwtracing/coresight/coresight-etm-perf.h | 15 ++
drivers/hwtracing/coresight/coresight-priv.h | 2 -
drivers/hwtracing/coresight/coresight-syscfg.c | 6 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 6 +-
drivers/hwtracing/coresight/coresight-tmc-etf.c | 44 ++---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 207 +++++++++++++----------
drivers/hwtracing/coresight/coresight-tmc.h | 30 ++--
drivers/hwtracing/coresight/coresight-trbe.c | 3 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 25 +--
drivers/hwtracing/coresight/ultrasoc-smb.h | 6 +-
include/linux/coresight.h | 5 +-
14 files changed, 294 insertions(+), 195 deletions(-)
---
base-commit: 98495b5a4d77dd22e106f462b76e1093a55b29a7
change-id: 20260708-james-cs-multiple-per-threads-ed1d25ed1734

Best regards,
--
James Clark <james.clark@xxxxxxxxxx>