Skip to contentSkip to conversation

perf script: Fix error when printing 'weight' field

PATCH Applied German Gomez 3 participants 3 messages Feb 21, 2022 – Feb 23, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf script: Fix error when printing 'weight' field

In SPE traces the 'weight' field can't be printed in perf-script because the 'dummy:u' event doesn't have the WEIGHT attribute set.

Use evsel__do_check_stype(..) to check this field, as it's done with other fields such as "phys_addr".

Before:

$ perf record -e arm_spe_0// -- sleep 1
$ perf script -F event,ip,weight
Samples for 'dummy:u' event do not have WEIGHT attribute set. Cannot print 'weight' field.

After:

$ perf script -F event,ip,weight
   l1d-access:               12 ffffaf629d4cb320
   tlb-access:               12 ffffaf629d4cb320
       memory:               12 ffffaf629d4cb320
Fixes b0fde9c6e291 ("perf arm-spe: Add SPE total latency as PERF_SAMPLE_WEIGHT")
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
index 9e032343f..6ce581067 100644
@@ -463,7 +463,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(WEIGHT) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
+	    evsel__do_check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT, allow_user_set))
 		return -EINVAL;
 
 	if (PRINT_FIELD(SYM) &&
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · German Gomez

In SPE traces the 'weight' field can't be printed in perf-script because the 'dummy:u' event doesn't have the WEIGHT attribute set.

Use evsel__do_check_stype(..) to check this field, as it's done with other fields such as "phys_addr".

Before:

$ perf record -e arm_spe_0// -- sleep 1
$ perf script -F event,ip,weight
Samples for 'dummy:u' event do not have WEIGHT attribute set. Cannot print 'weight' field.

After:

Quoted 7 lines
$ perf script -F event,ip,weight
   l1d-access:               12 ffffaf629d4cb320
   tlb-access:               12 ffffaf629d4cb320
       memory:               12 ffffaf629d4cb320
Fixes b0fde9c6e291 ("perf arm-spe: Add SPE total latency as PERF_SAMPLE_WEIGHT")

thanks,
jirka

Quoted 20 lines
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
index 9e032343f..6ce581067 100644
@@ -463,7 +463,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(WEIGHT) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
+	    evsel__do_check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT, allow_user_set))
 		return -EINVAL;
 
 	if (PRINT_FIELD(SYM) &&
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw

Em Mon, Feb 21, 2022 at 08:46:32PM +0100, Jiri Olsa escreveu:

Quoted 20 lines · German Gomez
Quoted 19 lines

In SPE traces the 'weight' field can't be printed in perf-script because the 'dummy:u' event doesn't have the WEIGHT attribute set.

Use evsel__do_check_stype(..) to check this field, as it's done with other fields such as "phys_addr".

Before:

$ perf record -e arm_spe_0// -- sleep 1
$ perf script -F event,ip,weight
Samples for 'dummy:u' event do not have WEIGHT attribute set. Cannot print 'weight' field.

After:

$ perf script -F event,ip,weight
   l1d-access:               12 ffffaf629d4cb320
   tlb-access:               12 ffffaf629d4cb320
       memory:               12 ffffaf629d4cb320
Quoted 4 lines
Quoted 2 lines
Fixes b0fde9c6e291 ("perf arm-spe: Add SPE total latency as PERF_SAMPLE_WEIGHT")

Thanks, applied to perf/urgent.

- Arnaldo

Quoted 23 lines

thanks,
jirka

Quoted 20 lines
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
index 9e032343f..6ce581067 100644
@@ -463,7 +463,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
 		return -EINVAL;
 
 	if (PRINT_FIELD(WEIGHT) &&
-	    evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT))
+	    evsel__do_check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT, allow_user_set))
 		return -EINVAL;
 
 	if (PRINT_FIELD(SYM) &&
Signature · 1 line
2.25.1
Signature · 1 line
- Arnaldo