perf cgroup: simplify arguments if track multiple events for a cgroup
RFC PATCH 1/1 perf cgroup: simplify arguments if track multiple events for a cgroup
if use -G with one cgroup and -e with multiple events, only the first event has correct cgroup setting, all events from the second will track system-wide events.
if user want track multiple events for a specific cgroup, user must give parameters like follow:
$ perf stat -e e1 -e e2 -e e3 -G test,test,test this patch simplify this case, just type one cgroup, like following: $ perf stat -e e1 -e e2 -e e3 -G test
reproduce:
$ mkdir -p /sys/fs/cgroup/perf_event/test $ perf stat -e cycles -e cache-misses -a -I 1000 -G test
before:
1.001007226 <not counted> cycles test
1.001007226 7,506 cache-misses
after:
1.000834097 <not counted> cycles test
1.000834097 <not counted> cache-misses test--- tools/perf/util/cgroup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
tools/perf/util/cgroup.c +16 -1
@@ -154,9 +154,11 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str, int unset __maybe_unused) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; +struct perf_evsel *counter; +struct cgroup_sel *cgrp =NULL ;const char *p, *e, *eos = str +strlen (str);char *s; -int ret; +int ret, i;if (list_empty (&evlist->entries)) {fprintf (stderr,"must define events before cgroups\n" );
@@ -185,5 +187,18 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str,break ; str = p+1 ; } +/* for the case one cgroup combine to multiple events */ + i =0 ; +if (nr_cgroups ==1 ) { +evlist__for_each_entry (evlist, counter) { +if (i ==0 ) + cgrp = counter->cgrp; +else { + counter->cgrp = cgrp; +refcount_inc (&cgrp->refcnt); + } + i++; + } + }return 0 ; }
Signature · 1 line
2.9.4
Quoted 18 lines · weiping zhang
if use -G with one cgroup and -e with multiple events, only the first event has correct cgroup setting, all events from the second will track system-wide events.
if user want track multiple events for a specific cgroup, user must give parameters like follow:
$ perf stat -e e1 -e e2 -e e3 -G test,test,test this patch simplify this case, just type one cgroup, like following: $ perf stat -e e1 -e e2 -e e3 -G testreproduce:
$ mkdir -p /sys/fs/cgroup/perf_event/test $ perf stat -e cycles -e cache-misses -a -I 1000 -G testbefore:
1.001007226 <not counted> cycles test
1.001007226 7,506 cache-misses
Quoted 8 lines
after:
1.000834097 <not counted> cycles test 1.000834097 <not counted> cache-misses testSigned-off-by weiping zhang <[email protected]>--- tools/perf/util/cgroup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
please update the -G option documentation
Quoted 19 lines
tools/perf/util/cgroup.c +3
-1@@ -154,9 +154,11 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str, int unset __maybe_unused) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; +struct perf_evsel *counter; +struct cgroup_sel *cgrp =NULL ;const char *p, *e, *eos = str +strlen (str);char *s; -int ret; +int ret, i;if (list_empty (&evlist->entries)) {fprintf (stderr,"must define events before cgroups\n" );
tools/perf/util/cgroup.c int parse_cgroups(const struct option *opt __maybe_unused, const char *str, · line 195
Quoted 9 lines
tools/perf/util/cgroup.c +6
-0@@ -185,5 +187,18 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str,break ; str = p+1 ; } +/* for the case one cgroup combine to multiple events */ + i =0 ; +if (nr_cgroups ==1 ) { +evlist__for_each_entry (evlist, counter) { +if (i ==0 ) + cgrp = counter->cgrp;
what if the only group is not defined for the first event? like -G ,,krava
thanks,
jirka
2018-01-29 18:39 GMT+08:00 Jiri Olsa <[email protected]>:
Quoted 23 lines · weiping zhang
Quoted 22 lines
if use -G with one cgroup and -e with multiple events, only the first event has correct cgroup setting, all events from the second will track system-wide events.
if user want track multiple events for a specific cgroup, user must give parameters like follow:
$ perf stat -e e1 -e e2 -e e3 -G test,test,test this patch simplify this case, just type one cgroup, like following: $ perf stat -e e1 -e e2 -e e3 -G testreproduce:
$ mkdir -p /sys/fs/cgroup/perf_event/test $ perf stat -e cycles -e cache-misses -a -I 1000 -G testbefore:
1.001007226 <not counted> cycles test
1.001007226 7,506 cache-missesafter:
1.000834097 <not counted> cycles test 1.000834097 <not counted> cache-misses test
Quoted 7 lines
Quoted 4 lines
Signed-off-by weiping zhang <[email protected]>--- tools/perf/util/cgroup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)please update the -G option documentation
OK, I'll add that at V2.
Quoted 16 lines
Quoted 16 lines
tools/perf/util/cgroup.c +3
-1@@ -154,9 +154,11 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str, int unset __maybe_unused) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; +struct perf_evsel *counter; +struct cgroup_sel *cgrp =NULL ;const char *p, *e, *eos = str +strlen (str);char *s; -int ret; +int ret, i;
Quoted 15 lines
tools/perf/util/cgroup.c int parse_cgroups(const struct option *opt __maybe_unused, const char *str, · line 195
Quoted 12 lines
tools/perf/util/cgroup.c +6
-0if (list_empty (&evlist->entries)) {fprintf (stderr,"must define events before cgroups\n" );@@ -185,5 +187,18 @@ int parse_cgroups(const struct option *opt __maybe_unused, const char *str,break ; str = p+1 ; } +/* for the case one cgroup combine to multiple events */ + i =0 ; +if (nr_cgroups ==1 ) { +evlist__for_each_entry (evlist, counter) { +if (i ==0 ) + cgrp = counter->cgrp;what if the only group is not defined for the first event? like -G ,,krava
if there is a comma, the nr_cgrous will > 1, so it will keep original behavior track system-wide events.
Quoted 2 lines
thanks,
jirka