Skip to contentSkip to conversation

perf test: Use generic event for expand_libpfm_events()

PATCH Superseded Namhyung Kim 5 participants 9 messages Oct 24, 2020 – Oct 27, 2020 perf events

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/2 perf test: Use generic event for expand_libpfm_events()

I found that the UNHALTED_CORE_CYCLES event is only available in the Intel machines and it makes other vendors/archs fail on the test. As libpfm4 can parse the generic events like cycles, let's use them.

Fixes 40b74c30ffb9 ("perf test: Add expand cgroup event test")
---
 tools/perf/tests/expand-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/expand-cgroup.c +1 -1
index d5771e4d094f..4c59f3ae438f 100644
@@ -145,7 +145,7 @@ static int expand_libpfm_events(void)
 	int ret;
 	struct evlist *evlist;
 	struct rblist metric_events;
-	const char event_str[] = "UNHALTED_CORE_CYCLES";
+	const char event_str[] = "CYCLES";
 	struct option opt = {
 		.value = &evlist,
 	};
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
author maintainer
#1 lore raw

PATCH v2 2/2 perf stat: Support regex pattern in --for-each-cgroup

To make the command line even more compact with cgroups, support regex pattern matching in cgroup names.

  $ perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
          3,000.73 msec cpu-clock                 foo #    2.998 CPUs utilized
    12,530,992,699      cycles                    foo #    7.517 GHz                      (100.00%)
          1,000.61 msec cpu-clock                 foo/bar #    1.000 CPUs utilized
     4,178,529,579      cycles                    foo/bar #    2.506 GHz                      (100.00%)
          1,000.03 msec cpu-clock                 foo/baz #    0.999 CPUs utilized
     4,176,104,315      cycles                    foo/baz #    2.505 GHz                      (100.00%)
       1.000892614 seconds time elapsed
---
 tools/perf/Documentation/perf-stat.txt |   5 +-
 tools/perf/util/cgroup.c               | 192 +++++++++++++++++++++----
 2 files changed, 171 insertions(+), 26 deletions(-)
tools/perf/Documentation/perf-stat.txt +3 -2
index 9f9f29025e49..2b44c08b3b23 100644
@@ -168,8 +168,9 @@ command line can be used: 'perf stat -e cycles -G cgroup_name -a -e cycles'.
 
 --for-each-cgroup name::
 Expand event list for each cgroup in "name" (allow multiple cgroups separated
-by comma).  This has same effect that repeating -e option and -G option for
-each event x name.  This option cannot be used with -G/--cgroup option.
+by comma).  It also support regex patterns to match multiple groups.  This has same
+effect that repeating -e option and -G option for each event x name.  This option
+cannot be used with -G/--cgroup option.
 
 -o file::
 --output file::
tools/perf/util/cgroup.c +168 -24

244 lines not on this page · raw message

Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
#2 lore raw

Re: [PATCH v2 2/2] perf stat: Support regex pattern in --for-each-cgroup

Quoted 11 lines · Namhyung Kim

To make the command line even more compact with cgroups, support regex pattern matching in cgroup names.

  $ perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
          3,000.73 msec cpu-clock                 foo #    2.998 CPUs utilized
    12,530,992,699      cycles                    foo #    7.517 GHz                      (100.00%)
          1,000.61 msec cpu-clock                 foo/bar #    1.000 CPUs utilized
     4,178,529,579      cycles                    foo/bar #    2.506 GHz                      (100.00%)
          1,000.03 msec cpu-clock                 foo/baz #    0.999 CPUs utilized
     4,176,104,315      cycles                    foo/baz #    2.505 GHz                      (100.00%)

just curious.. there was another foo/XXX group using the rest of the cycles, right?

also perhaps we want to warn if there's no match found:

	$ sudo ./perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
	 Performance counter stats for 'system wide':


	       1.002375575 seconds time elapsed

jirka

author maintainer
#3 lore raw

Re: [PATCH v2 2/2] perf stat: Support regex pattern in --for-each-cgroup

Hi Jiri,

Quoted 14 lines · Jiri Olsa
Quoted 11 lines · Namhyung Kim

To make the command line even more compact with cgroups, support regex pattern matching in cgroup names.

  $ perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
          3,000.73 msec cpu-clock                 foo #    2.998 CPUs utilized
    12,530,992,699      cycles                    foo #    7.517 GHz                      (100.00%)
          1,000.61 msec cpu-clock                 foo/bar #    1.000 CPUs utilized
     4,178,529,579      cycles                    foo/bar #    2.506 GHz                      (100.00%)
          1,000.03 msec cpu-clock                 foo/baz #    0.999 CPUs utilized
     4,176,104,315      cycles                    foo/baz #    2.505 GHz                      (100.00%)
Quoted 2 lines

just curious.. there was another foo/XXX group using the rest of the cycles, right?

No, if so it should be displayed too. But actually there was a process in the foo cgroup itself.

Quoted 10 lines

also perhaps we want to warn if there's no match found:

        $ sudo ./perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1

Performance counter stats for 'system wide':

1.002375575 seconds time elapsed

Right, will check this case.

Thanks
Namhyung

#4 lore raw

Re: [PATCH v2 2/2] perf stat: Support regex pattern in --for-each-cgroup

Quoted 17 lines · Namhyung Kim

Hi Jiri,

Quoted 14 lines · Jiri Olsa
Quoted 11 lines · Namhyung Kim

To make the command line even more compact with cgroups, support regex pattern matching in cgroup names.

  $ perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
          3,000.73 msec cpu-clock                 foo #    2.998 CPUs utilized
    12,530,992,699      cycles                    foo #    7.517 GHz                      (100.00%)
          1,000.61 msec cpu-clock                 foo/bar #    1.000 CPUs utilized
     4,178,529,579      cycles                    foo/bar #    2.506 GHz                      (100.00%)
          1,000.03 msec cpu-clock                 foo/baz #    0.999 CPUs utilized
     4,176,104,315      cycles                    foo/baz #    2.505 GHz                      (100.00%)
Quoted 5 lines
Quoted 2 lines

just curious.. there was another foo/XXX group using the rest of the cycles, right?

No, if so it should be displayed too. But actually there was a process in the foo cgroup itself.

nah, right ;-) ok

jirka

Quoted 17 lines
Quoted 11 lines

also perhaps we want to warn if there's no match found:

        $ sudo ./perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1

Performance counter stats for 'system wide':

1.002375575 seconds time elapsed

Right, will check this case.

Thanks
Namhyung

#5 lore raw

Re: [PATCH v2 2/2] perf stat: Support regex pattern in --for-each-cgroup

In reply to Namhyung Kim

Em Mon, Oct 26, 2020 at 09:32:34PM +0900, Namhyung Kim escreveu:

Quoted 28 lines

Hi Jiri,

Quoted 14 lines · Jiri Olsa
Quoted 11 lines · Namhyung Kim

To make the command line even more compact with cgroups, support regex pattern matching in cgroup names.

  $ perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
          3,000.73 msec cpu-clock                 foo #    2.998 CPUs utilized
    12,530,992,699      cycles                    foo #    7.517 GHz                      (100.00%)
          1,000.61 msec cpu-clock                 foo/bar #    1.000 CPUs utilized
     4,178,529,579      cycles                    foo/bar #    2.506 GHz                      (100.00%)
          1,000.03 msec cpu-clock                 foo/baz #    0.999 CPUs utilized
     4,176,104,315      cycles                    foo/baz #    2.505 GHz                      (100.00%)
Quoted 2 lines

just curious.. there was another foo/XXX group using the rest of the cycles, right?

No, if so it should be displayed too. But actually there was a process in the foo cgroup itself.

Quoted 5 lines

also perhaps we want to warn if there's no match found:

        $ sudo ./perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
Quoted 7 lines
Quoted 5 lines

Performance counter stats for 'system wide':

1.002375575 seconds time elapsed

Right, will check this case.

Hum, I thought that could be done on top of this one, but then, the ambiguity of:

1. No samples for a cgroups matching that expression

2. No cgroups match that expression

Is real and warrants a warning for the 'no cgroups match the --for-each-group regexp' case.

So I'll wait for v3 with that warning,

Thanks,

- Arnaldo

author maintainer
#6 lore raw

Re: [PATCH v2 2/2] perf stat: Support regex pattern in --for-each-cgroup

Hi Arnaldo,

Quoted 20 lines · Arnaldo Carvalho de Melo

Em Mon, Oct 26, 2020 at 09:32:34PM +0900, Namhyung Kim escreveu:

Quoted 7 lines

Hi Jiri,

Quoted 4 lines · Jiri Olsa

also perhaps we want to warn if there's no match found:

        $ sudo ./perf stat -a -e cpu-clock,cycles --for-each-cgroup ^foo sleep 1
Quoted 7 lines
Quoted 5 lines

Performance counter stats for 'system wide':

1.002375575 seconds time elapsed

Right, will check this case.

Hum, I thought that could be done on top of this one, but then, the ambiguity of:

Quoted 6 lines

1. No samples for a cgroups matching that expression

2. No cgroups match that expression

Is real and warrants a warning for the 'no cgroups match the --for-each-group regexp' case.

The 1 will be handled by perf stat showing <not counted> and I'll add a warning for the item 2 like below:

  # perf stat -a -e cycles --for-each-cgroup ^foo sleep 1
  no cgroup matched: ^foo

Usage: perf stat [<options>] [<command>]

--for-each-cgroup <name>
expand events for each cgroup

Thanks
Namhyung

#7 lore raw
In reply to Namhyung Kim
Quoted 6 lines · Namhyung Kim

I found that the UNHALTED_CORE_CYCLES event is only available in the Intel machines and it makes other vendors/archs fail on the test. As libpfm4 can parse the generic events like cycles, let's use them.

Fixes 40b74c30ffb9 ("perf test: Add expand cgroup event test")

So would the test still fail when libpfm is not compiled in?

-Andi

reviewer Acked-by on v1 1/2
#8 lore raw
In reply to Namhyung Kim
Quoted 7 lines · Namhyung Kim

I found that the UNHALTED_CORE_CYCLES event is only available in the Intel machines and it makes other vendors/archs fail on the test. As libpfm4 can parse the generic events like cycles, let's use them.

Fixes 40b74c30ffb9 ("perf test: Add expand cgroup event test")

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/tests/expand-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/expand-cgroup.c +1 -2
index d5771e4d094f..4c59f3ae438f 100644
@@ -145,7 +145,7 @@ static int expand_libpfm_events(void)
        int ret;
        struct evlist *evlist;
        struct rblist metric_events;
-       const char event_str[] = "UNHALTED_CORE_CYCLES";
+       const char event_str[] = "CYCLES";
        struct option opt = {
                .value = &evlist,
        };
--

2.29.0.rc1.297.gfa9743e501-goog