Skip to contentSkip to conversation

perf cgroup: fix cgroup for multiple events

PATCH In review weiping zhang 2 participants 2 messages Jan 25, 2018 – Jan 26, 2018 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf cgroup: fix cgroup for multiple events

if use -G and with multiple events, only the first event has correct cgroup setting, all other events have a wroung setting.

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/cgroup.c +2 -1
index d9ffc1e..b50bfd1 100644
@@ -137,7 +137,8 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
 
 	return -1;
 found:
-	counter->cgrp = cgrp;
+	evlist__for_each_entry(evlist, counter)
+		counter->cgrp = cgrp;
 	return 0;
 }
 
Signature · 1 line
2.9.4
#1 lore raw

please discard this patch, may the right way to use cgroup with multiple events like following:

perf stat -e cycles -e cache-misses -a -I 1000 -G test,test

2018-01-25 23:00 GMT+08:00 weiping zhang <[email protected]>:

Quoted 37 lines

if use -G and with multiple events, only the first event has correct cgroup setting, all other events have a wroung setting.

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/cgroup.c +2 -2
index d9ffc1e..b50bfd1 100644
@@ -137,7 +137,8 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
 
        return -1;
 found:
-       counter->cgrp = cgrp;
+       evlist__for_each_entry(evlist, counter)
+               counter->cgrp = cgrp;
        return 0;
 }
 
--

2.9.4