mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 00/10] coresight: Prevent per-thread events from sharing a sink
@ 2026-10-16 10:46 James Clark
  2026-10-16 10:46 ` [PATCH v4 01/10] coresight: configfs: Don't assume active until cscfg_mgr is set James Clark
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: James Clark @ 2026-10-16 10:46 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, Leo Yan, Suyash Mahar, Yeoreum Yun
  Cc: Greg Kroah-Hartman, Qi Liu, Junhao He, coresight,
	linux-arm-kernel, linux-kernel, James Clark, Jonathan Cameron

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@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-6aee7579f1dc@linaro.org

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@linaro.org

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@linaro.org

---
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@linaro.org>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-10-16 10:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 10:46 [PATCH v4 00/10] coresight: Prevent per-thread events from sharing a sink James Clark
2026-10-16 10:46 ` [PATCH v4 01/10] coresight: configfs: Don't assume active until cscfg_mgr is set James Clark
2026-10-16 10:46 ` [PATCH v4 02/10] coresight: etm-perf: Remove workqueue for freeing AUX data James Clark
2026-10-16 10:46 ` [PATCH v4 03/10] coresight: etm-perf: Serialize AUX topology access James Clark
2026-10-16 10:46 ` [PATCH v4 04/10] coresight: etm-perf: Reject event if building path fails James Clark
2026-10-16 10:46 ` [PATCH v4 05/10] coresight: etm-perf: Prevent sink sharing at setup time James Clark
2026-10-16 10:46 ` [PATCH v4 06/10] coresight: tmc-etr: Reflect new sharing rules in allocator James Clark
2026-10-16 10:46 ` [PATCH v4 07/10] coresight: tmc-etr: Remove sharing guards from ETR James Clark
2026-10-16 10:46 ` [PATCH v4 08/10] coresight: tmc-etf: Remove sharing guards from ETF James Clark
2026-10-16 10:46 ` [PATCH v4 09/10] coresight: etb10: Remove sharing guards from ETB10 James Clark
2026-10-16 10:46 ` [PATCH v4 10/10] coresight: ultrasoc-smb: Remove sharing guards from SMB James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®