[SRU][N:gke][PATCH 102/106] perf cs-etm: Fix the assert() to handle captured and unprocessed cpu trace

Tim Whisonant tim.whisonant at canonical.com
Mon Jul 21 16:22:25 UTC 2025


From: Ilkka Koskinen <ilkka at os.amperecomputing.com>

BugLink: https://bugs.launchpad.net/bugs/2117098

If one builds perf with DEBUG=1, captures data on multiple CPUs and
finally runs 'perf report -C <cpu>' for only one of the cpus, assert()
aborts the program. This happens because there are empty queues with
format set.

This patch changes the condition to abort only if a queue is not empty
and if the format is unset.

  $ make -C tools/perf DEBUG=1 CORESIGHT=1 CSLIBS=/usr/lib CSINCLUDES=/usr/include install
  $ perf record -o kcore --kcore -e cs_etm/timestamp/k -s -C 0-1 dd if=/dev/zero of=/dev/null bs=1M count=1
  $ perf report --input kcore/data --vmlinux=/home/ikoskine/projects/linux/vmlinux -C 1
  Aborted (core dumped)

Fixes: 57880a7966be510c ("perf: cs-etm: Allocate queues for all CPUs")
Reviewed-by: James Clark <james.clark at linaro.org>
Signed-off-by: Ilkka Koskinen <ilkka at os.amperecomputing.com>
Cc: Adrian Hunter <adrian.hunter at intel.com>
Cc: Alexander Shishkin <alexander.shishkin at linux.intel.com>
Cc: Ian Rogers <irogers at google.com>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: James Clark <james.clark at linaro.org>
Cc: Jiri Olsa <jolsa at kernel.org>
Cc: John Garry <john.g.garry at oracle.com>
Cc: Kan Liang <kan.liang at linux.intel.com>
Cc: Leo Yan <leo.yan at linux.dev>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: Mike Leach <mike.leach at linaro.org>
Cc: Namhyung Kim <namhyung at kernel.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose at arm.com>
Cc: Will Deacon <will at kernel.org>
Link: https://lore.kernel.org/r/20240924233930.5193-1-ilkka@os.amperecomputing.com
Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>
(cherry picked from commit e934a35e3cc1fe0bfb1bc771e64f3ba6e70c40e2)
Signed-off-by: Tim Whisonant <tim.whisonant at canonical.com>
---
 tools/perf/util/cs-etm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 7c931f0c9ab3e..16beaf6c73c20 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -3359,7 +3359,7 @@ static int cs_etm__create_decoders(struct cs_etm_auxtrace *etm)
 		 * Don't create decoders for empty queues, mainly because
 		 * etmq->format is unknown for empty queues.
 		 */
-		assert(empty == (etmq->format == UNSET));
+		assert(empty || etmq->format != UNSET);
 		if (empty)
 			continue;
 
-- 
2.43.0




More information about the kernel-team mailing list