Skip to contentSkip to conversation

perf test: Enable system wide for metricgroups test

PATCH Superseded Ian Rogers 3 participants 6 messages Nov 23, 2021 – Nov 30, 2021 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/2 perf test: Enable system wide for metricgroups test

Uncore events as group leaders fail in per-thread mode causing exit errors. Enable system-wide for metricgroup testing. This fixes the HPC metric group when tested on skylakex.

Fixes 4a87dea9e60f ("perf test: Workload test of metric and metricgroups")
---
 tools/perf/tests/shell/stat_all_metricgroups.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_all_metricgroups.sh +1 -1
index de24d374ce24..cb35e488809a 100755
@@ -6,7 +6,7 @@ set -e
 
 for m in $(perf list --raw-dump metricgroups); do
   echo "Testing $m"
-  perf stat -M "$m" true
+  perf stat -M "$m" -a true
 done
 
 exit 0
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
author reviewer
#1 lore raw

PATCH 2/2 perf evsel: Improve error message for uncore events

When a group has multiple events and the leader fails it can yield errors like:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/).
/bin/dmesg | grep -i perf may provide additional information.

However, when not the group leader <not supported> is given:

$ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true
...
         1,619,057      instructions
   <not supported> MiB  uncore_imc/cas_count_read/

This is necessary because get_group_fd will fail if the leader fails and is the direct result of the check on line 750 of builtin-stat.c in stat_handle_error that returns COUNTER_SKIP for the latter case.

This patch improves the error message to:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'.
---
 tools/perf/util/evsel.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/util/evsel.c +5 -0
index a59fb2ecb84e..48696ff4bddb 100644
@@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
 			return scnprintf(msg, size, "wrong clockid (%d).", clockid);
 		if (perf_missing_features.aux_output)
 			return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
+		if ((evsel__leader(evsel) == evsel) &&
+		    (evsel->core.leader->nr_members > 1))
+			return scnprintf(msg, size,
+	"Invalid event (%s) in per-thread mode, enable system wide with '-a'.",
+					evsel__name(evsel));
 		break;
 	case ENODATA:
 		return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
#2 lore raw

Re: [PATCH 2/2] perf evsel: Improve error message for uncore events

Quoted 35 lines · Ian Rogers

When a group has multiple events and the leader fails it can yield errors like:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/).
/bin/dmesg | grep -i perf may provide additional information.

However, when not the group leader <not supported> is given:

$ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true
...
         1,619,057      instructions
   <not supported> MiB  uncore_imc/cas_count_read/

This is necessary because get_group_fd will fail if the leader fails and is the direct result of the check on line 750 of builtin-stat.c in stat_handle_error that returns COUNTER_SKIP for the latter case.

This patch improves the error message to:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'.
---
 tools/perf/util/evsel.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/util/evsel.c +0 -0
index a59fb2ecb84e..48696ff4bddb 100644

tools/perf/util/evsel.c int evsel__open_strerror(struct evsel *evsel, struct target *target, · line 2957

Quoted 8 lines
tools/perf/util/evsel.c +5 -0
@@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
 			return scnprintf(msg, size, "wrong clockid (%d).", clockid);
 		if (perf_missing_features.aux_output)
 			return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
+		if ((evsel__leader(evsel) == evsel) &&
+		    (evsel->core.leader->nr_members > 1))
+			return scnprintf(msg, size,
+	"Invalid event (%s) in per-thread mode, enable system wide with '-a'.",
+					evsel__name(evsel));

should we rather check 'target' pointer for the per-thread mode? I'm not sure that per-thread mode will always be the case for the failure

jirka

Quoted 6 lines
tools/perf/util/evsel.c +0 -0
 		break;
 	case ENODATA:
 		return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
author reviewer
#3 lore raw

Re: [PATCH 2/2] perf evsel: Improve error message for uncore events

Quoted 32 lines · Jiri Olsa
Quoted 30 lines · Ian Rogers

When a group has multiple events and the leader fails it can yield errors like:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/).
/bin/dmesg | grep -i perf may provide additional information.

However, when not the group leader <not supported> is given:

$ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true
...
         1,619,057      instructions
   <not supported> MiB  uncore_imc/cas_count_read/

This is necessary because get_group_fd will fail if the leader fails and is the direct result of the check on line 750 of builtin-stat.c in stat_handle_error that returns COUNTER_SKIP for the latter case.

This patch improves the error message to:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'.
---
 tools/perf/util/evsel.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 16 lines

tools/perf/util/evsel.c int evsel__open_strerror(struct evsel *evsel, struct target *target, · line 2957

Quoted 13 lines
tools/perf/util/evsel.c +5 -0
index a59fb2ecb84e..48696ff4bddb 100644
@@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
                      return scnprintf(msg, size, "wrong clockid (%d).", clockid);
              if (perf_missing_features.aux_output)
                      return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
+             if ((evsel__leader(evsel) == evsel) &&
+                 (evsel->core.leader->nr_members > 1))
+                     return scnprintf(msg, size,
+     "Invalid event (%s) in per-thread mode, enable system wide with '-a'.",
+                                     evsel__name(evsel));

should we rather check 'target' pointer for the per-thread mode? I'm not sure that per-thread mode will always be the case for the failure

Unfortunately the target isn't populated at that point:

gdb --args perf stat -e '{uncore_imc/cas_count_write/},instructions' /bin/true (gdb) p *target
$2 = {pid = 0x0, tid = 0x0, cpu_list = 0x0, uid_str = 0x0, bpf_str = 0x0, uid = 4294967295, system_wide = false, uses_mmap = false,
default_per_cpu = false, per_thread = false, use_bpf = false, hybrid
= false, attr_map = 0x0}

#0 evsel__open_strerror (evsel=0x616000015680, target=0x5555586aa140 <target>, err=22, msg=0x7fffffff78d0 "]k\264WUU", size=8192)

    at util/evsel.c:2857

#1 0x00005555561744e8 in stat_handle_error (counter=0x616000015680) at builtin-stat.c:771
#2 0x0000555556174f05 in __run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:852
#3 0x00005555561763e1 in run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:1048
#4 0x000055555617df82 in cmd_stat (argc=1, argv=0x7fffffffe450) at builtin-stat.c:2550
#5 0x00005555562f36b8 in run_builtin (p=0x5555586bad00 <commands+288>, argc=4, argv=0x7fffffffe450) at perf.c:313
#6 0x00005555562f3c11 in handle_internal_command (argc=4, argv=0x7fffffffe450) at perf.c:365
#7 0x00005555562f3fce in run_argv (argcp=0x7fffffffe230, argv=0x7fffffffe240) at perf.c:409
#8 0x00005555562f47bd in main (argc=4, argv=0x7fffffffe450) at perf.c:539

Thanks,
Ian

Quoted 9 lines

jirka

Quoted 6 lines
tools/perf/util/evsel.c +0 -1
              break;
      case ENODATA:
              return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
--

2.34.0.rc2.393.gf8c9666880-goog

maintainer
#4 lore raw

Re: [PATCH 2/2] perf evsel: Improve error message for uncore events

Hi Ian,

Quoted 51 lines · Ian Rogers
Quoted 32 lines · Jiri Olsa
Quoted 30 lines · Ian Rogers

When a group has multiple events and the leader fails it can yield errors like:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/).
/bin/dmesg | grep -i perf may provide additional information.

However, when not the group leader <not supported> is given:

$ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true
...
         1,619,057      instructions
   <not supported> MiB  uncore_imc/cas_count_read/

This is necessary because get_group_fd will fail if the leader fails and is the direct result of the check on line 750 of builtin-stat.c in stat_handle_error that returns COUNTER_SKIP for the latter case.

This patch improves the error message to:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'.
---
 tools/perf/util/evsel.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 16 lines

tools/perf/util/evsel.c int evsel__open_strerror(struct evsel *evsel, struct target *target, · line 2957

Quoted 13 lines
tools/perf/util/evsel.c +5 -0
index a59fb2ecb84e..48696ff4bddb 100644
@@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
                      return scnprintf(msg, size, "wrong clockid (%d).", clockid);
              if (perf_missing_features.aux_output)
                      return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
+             if ((evsel__leader(evsel) == evsel) &&
+                 (evsel->core.leader->nr_members > 1))
+                     return scnprintf(msg, size,
+     "Invalid event (%s) in per-thread mode, enable system wide with '-a'.",
+                                     evsel__name(evsel));

should we rather check 'target' pointer for the per-thread mode? I'm not sure that per-thread mode will always be the case for the failure

Quoted 1 line

Unfortunately the target isn't populated at that point:

It might be populated properly, as in this case
it should have no target. I think you can use
!target__has_cpu().

Thanks,
Namhyung

Quoted 39 lines

gdb --args perf stat -e '{uncore_imc/cas_count_write/},instructions' /bin/true (gdb) p *target
$2 = {pid = 0x0, tid = 0x0, cpu_list = 0x0, uid_str = 0x0, bpf_str = 0x0, uid = 4294967295, system_wide = false, uses_mmap = false,
default_per_cpu = false, per_thread = false, use_bpf = false, hybrid
= false, attr_map = 0x0}

#0 evsel__open_strerror (evsel=0x616000015680, target=0x5555586aa140 <target>, err=22, msg=0x7fffffff78d0 "]k\264WUU", size=8192)

    at util/evsel.c:2857

#1 0x00005555561744e8 in stat_handle_error (counter=0x616000015680) at builtin-stat.c:771
#2 0x0000555556174f05 in __run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:852
#3 0x00005555561763e1 in run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:1048
#4 0x000055555617df82 in cmd_stat (argc=1, argv=0x7fffffffe450) at builtin-stat.c:2550
#5 0x00005555562f36b8 in run_builtin (p=0x5555586bad00 <commands+288>, argc=4, argv=0x7fffffffe450) at perf.c:313
#6 0x00005555562f3c11 in handle_internal_command (argc=4, argv=0x7fffffffe450) at perf.c:365
#7 0x00005555562f3fce in run_argv (argcp=0x7fffffffe230, argv=0x7fffffffe240) at perf.c:409
#8 0x00005555562f47bd in main (argc=4, argv=0x7fffffffe450) at perf.c:539

Thanks,
Ian

Quoted 9 lines

jirka

Quoted 6 lines
tools/perf/util/evsel.c +0 -1
              break;
      case ENODATA:
              return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
--

2.34.0.rc2.393.gf8c9666880-goog

author reviewer
#5 lore raw

Re: [PATCH 2/2] perf evsel: Improve error message for uncore events

Quoted 55 lines · Namhyung Kim

Hi Ian,

Quoted 51 lines · Ian Rogers
Quoted 48 lines · Jiri Olsa
Quoted 35 lines · Ian Rogers

When a group has multiple events and the leader fails it can yield errors like:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc/cas_count_read/).
/bin/dmesg | grep -i perf may provide additional information.

However, when not the group leader <not supported> is given:

$ perf stat -e '{instructions,uncore_imc/cas_count_read/}' /bin/true
...
         1,619,057      instructions
   <not supported> MiB  uncore_imc/cas_count_read/

This is necessary because get_group_fd will fail if the leader fails and is the direct result of the check on line 750 of builtin-stat.c in stat_handle_error that returns COUNTER_SKIP for the latter case.

This patch improves the error message to:

$ perf stat -e '{uncore_imc/cas_count_read/},instructions' /bin/true
Error:
Invalid event (uncore_imc/cas_count_read/) in per-thread mode, enable system wide with '-a'.
---
 tools/perf/util/evsel.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/util/evsel.c +0 -0
index a59fb2ecb84e..48696ff4bddb 100644

tools/perf/util/evsel.c int evsel__open_strerror(struct evsel *evsel, struct target *target, · line 2957

Quoted 8 lines
tools/perf/util/evsel.c +5 -0
@@ -2950,6 +2950,11 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
                      return scnprintf(msg, size, "wrong clockid (%d).", clockid);
              if (perf_missing_features.aux_output)
                      return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel.");
+             if ((evsel__leader(evsel) == evsel) &&
+                 (evsel->core.leader->nr_members > 1))
+                     return scnprintf(msg, size,
+     "Invalid event (%s) in per-thread mode, enable system wide with '-a'.",
+                                     evsel__name(evsel));

should we rather check 'target' pointer for the per-thread mode? I'm not sure that per-thread mode will always be the case for the failure

Quoted 5 lines
Quoted 1 line

Unfortunately the target isn't populated at that point:

It might be populated properly, as in this case
it should have no target. I think you can use
!target__has_cpu().

Thanks :-) I'm not sure having !target__has_cpu is intention revealing. Perhaps changing the error to say that an invalid/unsupported event can't be the group leader, unless it is the only event, and then suggest system wide mode.

Thanks,
Ian

Quoted 43 lines

Thanks,
Namhyung

Quoted 39 lines

gdb --args perf stat -e '{uncore_imc/cas_count_write/},instructions' /bin/true (gdb) p *target
$2 = {pid = 0x0, tid = 0x0, cpu_list = 0x0, uid_str = 0x0, bpf_str = 0x0, uid = 4294967295, system_wide = false, uses_mmap = false,
default_per_cpu = false, per_thread = false, use_bpf = false, hybrid
= false, attr_map = 0x0}

#0 evsel__open_strerror (evsel=0x616000015680, target=0x5555586aa140 <target>, err=22, msg=0x7fffffff78d0 "]k\264WUU", size=8192)

    at util/evsel.c:2857

#1 0x00005555561744e8 in stat_handle_error (counter=0x616000015680) at builtin-stat.c:771
#2 0x0000555556174f05 in __run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:852
#3 0x00005555561763e1 in run_perf_stat (argc=1, argv=0x7fffffffe450, run_idx=0) at builtin-stat.c:1048
#4 0x000055555617df82 in cmd_stat (argc=1, argv=0x7fffffffe450) at builtin-stat.c:2550
#5 0x00005555562f36b8 in run_builtin (p=0x5555586bad00 <commands+288>, argc=4, argv=0x7fffffffe450) at perf.c:313
#6 0x00005555562f3c11 in handle_internal_command (argc=4, argv=0x7fffffffe450) at perf.c:365
#7 0x00005555562f3fce in run_argv (argcp=0x7fffffffe230, argv=0x7fffffffe240) at perf.c:409
#8 0x00005555562f47bd in main (argc=4, argv=0x7fffffffe450) at perf.c:539

Thanks,
Ian

Quoted 9 lines

jirka

Quoted 6 lines
tools/perf/util/evsel.c +0 -1
              break;
      case ENODATA:
              return scnprintf(msg, size, "Cannot collect data source with the load latency event alone. "
--

2.34.0.rc2.393.gf8c9666880-goog