aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-11-13 15:27:28 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-14 14:53:45 -0500
commit07ac002f2fcc74c5be47b656d9201d5de84dc53d (patch)
tree6f43107a76ed87f2b817594d2d62246ab82cfba6 /tools/perf
parent1483c2ae90738e7453bfe446a3bbcdd0ba9abf36 (diff)
perf evsel: Introduce is_group_member method
To clarify what is being tested, instead of assuming that evsel->leader == NULL means either an 'isolated' evsel or a 'group leader'. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-lvdbvimaxw9nc5een5vmem0c@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c3
-rw-r--r--tools/perf/tests/parse-events.c20
-rw-r--r--tools/perf/util/evlist.c4
-rw-r--r--tools/perf/util/evsel.c6
-rw-r--r--tools/perf/util/evsel.h6
5 files changed, 23 insertions, 16 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 557081e0c6d9..c247faca7127 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -152,7 +152,8 @@ retry:
152 return 0; 152 return 0;
153 } 153 }
154 154
155 if (!perf_target__has_task(&target) && (!evsel->leader)) { 155 if (!perf_target__has_task(&target) &&
156 !perf_evsel__is_group_member(evsel)) {
156 attr->disabled = 1; 157 attr->disabled = 1;
157 attr->enable_on_exec = 1; 158 attr->enable_on_exec = 1;
158 } 159 }
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index f2a82d0158c0..42a0c8cd3cd5 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -521,7 +521,7 @@ static int test__group1(struct perf_evlist *evlist)
521 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 521 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
522 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 522 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
523 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 523 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
524 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 524 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
525 525
526 /* cycles:upp */ 526 /* cycles:upp */
527 evsel = perf_evsel__next(evsel); 527 evsel = perf_evsel__next(evsel);
@@ -557,7 +557,7 @@ static int test__group2(struct perf_evlist *evlist)
557 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 557 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
558 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 558 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
559 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 559 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
560 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 560 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
561 561
562 /* cache-references + :u modifier */ 562 /* cache-references + :u modifier */
563 evsel = perf_evsel__next(evsel); 563 evsel = perf_evsel__next(evsel);
@@ -583,7 +583,7 @@ static int test__group2(struct perf_evlist *evlist)
583 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 583 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
584 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 584 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
585 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 585 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
586 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 586 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
587 587
588 return 0; 588 return 0;
589} 589}
@@ -606,7 +606,7 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused)
606 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 606 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
607 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 607 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
608 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 608 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
609 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 609 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
610 TEST_ASSERT_VAL("wrong group name", 610 TEST_ASSERT_VAL("wrong group name",
611 !strcmp(leader->group_name, "group1")); 611 !strcmp(leader->group_name, "group1"));
612 612
@@ -636,7 +636,7 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused)
636 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 636 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
637 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 637 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
638 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 638 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
639 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 639 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
640 TEST_ASSERT_VAL("wrong group name", 640 TEST_ASSERT_VAL("wrong group name",
641 !strcmp(leader->group_name, "group2")); 641 !strcmp(leader->group_name, "group2"));
642 642
@@ -663,7 +663,7 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused)
663 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 663 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
664 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 664 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
665 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 665 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
666 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 666 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
667 667
668 return 0; 668 return 0;
669} 669}
@@ -687,7 +687,7 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused)
687 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 687 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
688 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); 688 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
689 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 689 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
690 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 690 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
691 691
692 /* instructions:kp + p */ 692 /* instructions:kp + p */
693 evsel = perf_evsel__next(evsel); 693 evsel = perf_evsel__next(evsel);
@@ -724,7 +724,7 @@ static int test__group5(struct perf_evlist *evlist __maybe_unused)
724 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 724 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
725 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 725 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
726 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 726 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
727 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 727 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
728 728
729 /* instructions + G */ 729 /* instructions + G */
730 evsel = perf_evsel__next(evsel); 730 evsel = perf_evsel__next(evsel);
@@ -751,7 +751,7 @@ static int test__group5(struct perf_evlist *evlist __maybe_unused)
751 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 751 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
752 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 752 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
753 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 753 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
754 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 754 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
755 755
756 /* instructions:G */ 756 /* instructions:G */
757 evsel = perf_evsel__next(evsel); 757 evsel = perf_evsel__next(evsel);
@@ -777,7 +777,7 @@ static int test__group5(struct perf_evlist *evlist __maybe_unused)
777 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 777 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
778 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 778 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
779 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 779 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
780 TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); 780 TEST_ASSERT_VAL("wrong leader", !perf_evsel__is_group_member(evsel));
781 781
782 return 0; 782 return 0;
783} 783}
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e9d2d5da2fb8..705293489e3c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -222,7 +222,7 @@ void perf_evlist__disable(struct perf_evlist *evlist)
222 222
223 for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { 223 for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
224 list_for_each_entry(pos, &evlist->entries, node) { 224 list_for_each_entry(pos, &evlist->entries, node) {
225 if (pos->leader) 225 if (perf_evsel__is_group_member(pos))
226 continue; 226 continue;
227 for (thread = 0; thread < evlist->threads->nr; thread++) 227 for (thread = 0; thread < evlist->threads->nr; thread++)
228 ioctl(FD(pos, cpu, thread), 228 ioctl(FD(pos, cpu, thread),
@@ -238,7 +238,7 @@ void perf_evlist__enable(struct perf_evlist *evlist)
238 238
239 for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) { 239 for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) {
240 list_for_each_entry(pos, &evlist->entries, node) { 240 list_for_each_entry(pos, &evlist->entries, node) {
241 if (pos->leader) 241 if (perf_evsel__is_group_member(pos))
242 continue; 242 continue;
243 for (thread = 0; thread < evlist->threads->nr; thread++) 243 for (thread = 0; thread < evlist->threads->nr; thread++)
244 ioctl(FD(pos, cpu, thread), 244 ioctl(FD(pos, cpu, thread),
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index fc4faaa7afb9..1fb636c550a1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -519,14 +519,14 @@ void perf_evsel__config(struct perf_evsel *evsel,
519 * Disabling only independent events or group leaders, 519 * Disabling only independent events or group leaders,
520 * keeping group members enabled. 520 * keeping group members enabled.
521 */ 521 */
522 if (!evsel->leader) 522 if (!perf_evsel__is_group_member(evsel))
523 attr->disabled = 1; 523 attr->disabled = 1;
524 524
525 /* 525 /*
526 * Setting enable_on_exec for independent events and 526 * Setting enable_on_exec for independent events and
527 * group leaders for traced executed by perf. 527 * group leaders for traced executed by perf.
528 */ 528 */
529 if (perf_target__none(&opts->target) && (!evsel->leader)) 529 if (perf_target__none(&opts->target) && !perf_evsel__is_group_member(evsel))
530 attr->enable_on_exec = 1; 530 attr->enable_on_exec = 1;
531} 531}
532 532
@@ -707,7 +707,7 @@ static int get_group_fd(struct perf_evsel *evsel, int cpu, int thread)
707 struct perf_evsel *leader = evsel->leader; 707 struct perf_evsel *leader = evsel->leader;
708 int fd; 708 int fd;
709 709
710 if (!leader) 710 if (!perf_evsel__is_group_member(evsel))
711 return -1; 711 return -1;
712 712
713 /* 713 /*
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 32d7ec78dedc..a4c1dd4e149f 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include <stddef.h>
6#include "../../../include/uapi/linux/perf_event.h" 7#include "../../../include/uapi/linux/perf_event.h"
7#include "types.h" 8#include "types.h"
8#include "xyarray.h" 9#include "xyarray.h"
@@ -224,4 +225,9 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
224{ 225{
225 return list_entry(evsel->node.next, struct perf_evsel, node); 226 return list_entry(evsel->node.next, struct perf_evsel, node);
226} 227}
228
229static inline bool perf_evsel__is_group_member(const struct perf_evsel *evsel)
230{
231 return evsel->leader != NULL;
232}
227#endif /* __PERF_EVSEL_H */ 233#endif /* __PERF_EVSEL_H */