Skip to contentSkip to conversation

perf: cs-etm: Fix the assert() to handle captured and unprocessed cpu trace

PATCH In review Ilkka Koskinen 4 participants 4 messages Sep 24, 2024 – Oct 1, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: cs-etm: Fix the assert() to handle captured and unprocessed cpu trace

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 57880a7966be ("perf: cs-etm: Allocate queues for all CPUs")
---
 tools/perf/util/cs-etm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cs-etm.c +1 -1
index 90f32f327b9b..40f047baef81 100644
@@ -3323,7 +3323,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;
 
Signature · 1 line
2.42.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Ilkka Koskinen

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 57880a7966be ("perf: cs-etm: Allocate queues for all CPUs")
---
  tools/perf/util/cs-etm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cs-etm.c +0 -0
index 90f32f327b9b..40f047baef81 100644

tools/perf/util/cs-etm.c static int cs_etm__create_decoders(struct cs_etm_auxtrace *etm) · line 3329

Quoted 8 lines
tools/perf/util/cs-etm.c +1 -1
@@ -3323,7 +3323,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;
 

Oops I didn't realize you could filter on CPU in report mode. Thanks for the fix. Adding a test to the end of test_arm_coresight.sh might be quite useful. Either way:

maintainer
#2 lore raw
Quoted 37 lines · James Clark
Quoted 22 lines · Ilkka Koskinen

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 57880a7966be ("perf: cs-etm: Allocate queues for all CPUs")
---
  tools/perf/util/cs-etm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cs-etm.c +0 -0
index 90f32f327b9b..40f047baef81 100644

tools/perf/util/cs-etm.c static int cs_etm__create_decoders(struct cs_etm_auxtrace *etm) · line 3328

Quoted 7 lines
tools/perf/util/cs-etm.c +1 -1
@@ -3323,7 +3323,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;

Oops I didn't realize you could filter on CPU in report mode. Thanks for the fix. Adding a test to the end of test_arm_coresight.sh might be quite useful. Either way:

Quoted 1 line

Thanks, it should go to the perf-tool. Arnaldo, please pick up. Namhyung

#3 lore raw
Quoted 38 lines · Namhyung Kim
Quoted 37 lines · James Clark
Quoted 22 lines · Ilkka Koskinen

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 57880a7966be ("perf: cs-etm: Allocate queues for all CPUs")
---
  tools/perf/util/cs-etm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cs-etm.c +0 -0
index 90f32f327b9b..40f047baef81 100644

tools/perf/util/cs-etm.c static int cs_etm__create_decoders(struct cs_etm_auxtrace *etm) · line 3328

Quoted 7 lines
tools/perf/util/cs-etm.c +1 -1
@@ -3323,7 +3323,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;

Oops I didn't realize you could filter on CPU in report mode. Thanks for the fix. Adding a test to the end of test_arm_coresight.sh might be quite useful. Either way:

Quoted 3 lines
Quoted 1 line

Thanks, it should go to the perf-tool. Arnaldo, please pick up.

Right, picking it now.

Thanks,

- Arnaldo