diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-05 00:53:26 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 12:06:05 -0400 |
commit | 759ff497e0e6749437b6723f8d26de0b1833c199 (patch) | |
tree | e8105fb758da21ac4a796ee669d21efa12b1aabf /tools/perf | |
parent | b1dd443296b4f8c6869eba790eec950f80392aea (diff) |
perf evsel: Introduce perf_evsel__is_group_event() helper
The perf_evsel__is_group_event function is for checking whether given
evsel needs event group view support or not. Please note that it's
different to the existing perf_evsel__is_group_leader() which checks
only the given evsel is a leader or a standalone (i.e. non-group) event
regardless of event group feature.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362462812-30885-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-report.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 7 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 7 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 9 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 24 |
6 files changed, 34 insertions, 19 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 96b5a7fee4bb..3f4a79ba5ada 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -314,7 +314,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self, | |||
314 | char buf[512]; | 314 | char buf[512]; |
315 | size_t size = sizeof(buf); | 315 | size_t size = sizeof(buf); |
316 | 316 | ||
317 | if (symbol_conf.event_group && evsel->nr_members > 1) { | 317 | if (perf_evsel__is_group_event(evsel)) { |
318 | struct perf_evsel *pos; | 318 | struct perf_evsel *pos; |
319 | 319 | ||
320 | perf_evsel__group_desc(evsel, buf, size); | 320 | perf_evsel__group_desc(evsel, buf, size); |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 0e125e1543dc..a5843fd6ab51 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1193,7 +1193,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, | |||
1193 | char buf[512]; | 1193 | char buf[512]; |
1194 | size_t buflen = sizeof(buf); | 1194 | size_t buflen = sizeof(buf); |
1195 | 1195 | ||
1196 | if (symbol_conf.event_group && evsel->nr_members > 1) { | 1196 | if (perf_evsel__is_group_event(evsel)) { |
1197 | struct perf_evsel *pos; | 1197 | struct perf_evsel *pos; |
1198 | 1198 | ||
1199 | perf_evsel__group_desc(evsel, buf, buflen); | 1199 | perf_evsel__group_desc(evsel, buf, buflen); |
@@ -1709,7 +1709,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser, | |||
1709 | ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : | 1709 | ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : |
1710 | HE_COLORSET_NORMAL); | 1710 | HE_COLORSET_NORMAL); |
1711 | 1711 | ||
1712 | if (symbol_conf.event_group && evsel->nr_members > 1) { | 1712 | if (perf_evsel__is_group_event(evsel)) { |
1713 | struct perf_evsel *pos; | 1713 | struct perf_evsel *pos; |
1714 | 1714 | ||
1715 | ev_name = perf_evsel__group_name(evsel); | 1715 | ev_name = perf_evsel__group_name(evsel); |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 1e764a8ad259..6f259b3d14e2 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -32,21 +32,18 @@ static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
32 | int ret; | 32 | int ret; |
33 | double percent = 0.0; | 33 | double percent = 0.0; |
34 | struct hists *hists = he->hists; | 34 | struct hists *hists = he->hists; |
35 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
35 | 36 | ||
36 | if (hists->stats.total_period) | 37 | if (hists->stats.total_period) |
37 | percent = 100.0 * get_field(he) / hists->stats.total_period; | 38 | percent = 100.0 * get_field(he) / hists->stats.total_period; |
38 | 39 | ||
39 | ret = __percent_color_snprintf(hpp->buf, hpp->size, percent); | 40 | ret = __percent_color_snprintf(hpp->buf, hpp->size, percent); |
40 | 41 | ||
41 | if (symbol_conf.event_group) { | 42 | if (perf_evsel__is_group_event(evsel)) { |
42 | int prev_idx, idx_delta; | 43 | int prev_idx, idx_delta; |
43 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
44 | struct hist_entry *pair; | 44 | struct hist_entry *pair; |
45 | int nr_members = evsel->nr_members; | 45 | int nr_members = evsel->nr_members; |
46 | 46 | ||
47 | if (nr_members <= 1) | ||
48 | return ret; | ||
49 | |||
50 | prev_idx = perf_evsel__group_idx(evsel); | 47 | prev_idx = perf_evsel__group_idx(evsel); |
51 | 48 | ||
52 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { | 49 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index d671e63aa351..4bf91b09d62d 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -16,6 +16,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
16 | { | 16 | { |
17 | int ret; | 17 | int ret; |
18 | struct hists *hists = he->hists; | 18 | struct hists *hists = he->hists; |
19 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
19 | 20 | ||
20 | if (fmt_percent) { | 21 | if (fmt_percent) { |
21 | double percent = 0.0; | 22 | double percent = 0.0; |
@@ -28,15 +29,11 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
28 | } else | 29 | } else |
29 | ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he)); | 30 | ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he)); |
30 | 31 | ||
31 | if (symbol_conf.event_group) { | 32 | if (perf_evsel__is_group_event(evsel)) { |
32 | int prev_idx, idx_delta; | 33 | int prev_idx, idx_delta; |
33 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
34 | struct hist_entry *pair; | 34 | struct hist_entry *pair; |
35 | int nr_members = evsel->nr_members; | 35 | int nr_members = evsel->nr_members; |
36 | 36 | ||
37 | if (nr_members <= 1) | ||
38 | return ret; | ||
39 | |||
40 | prev_idx = perf_evsel__group_idx(evsel); | 37 | prev_idx = perf_evsel__group_idx(evsel); |
41 | 38 | ||
42 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { | 39 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0955cff5b0ef..f080cc40f00b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -649,9 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
649 | 649 | ||
650 | next = disasm__get_next_ip_line(¬es->src->source, dl); | 650 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
651 | 651 | ||
652 | if (symbol_conf.event_group && | 652 | if (perf_evsel__is_group_event(evsel)) { |
653 | perf_evsel__is_group_leader(evsel) && | ||
654 | evsel->nr_members > 1) { | ||
655 | nr_percent = evsel->nr_members; | 653 | nr_percent = evsel->nr_members; |
656 | ppercents = calloc(nr_percent, sizeof(double)); | 654 | ppercents = calloc(nr_percent, sizeof(double)); |
657 | if (ppercents == NULL) | 655 | if (ppercents == NULL) |
@@ -721,8 +719,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
721 | if (queue) | 719 | if (queue) |
722 | return -1; | 720 | return -1; |
723 | 721 | ||
724 | if (symbol_conf.event_group && | 722 | if (perf_evsel__is_group_event(evsel)) |
725 | perf_evsel__is_group_leader(evsel)) | ||
726 | width *= evsel->nr_members; | 723 | width *= evsel->nr_members; |
727 | 724 | ||
728 | if (!*dl->line) | 725 | if (!*dl->line) |
@@ -1126,7 +1123,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
1126 | len = symbol__size(sym); | 1123 | len = symbol__size(sym); |
1127 | namelen = strlen(d_filename); | 1124 | namelen = strlen(d_filename); |
1128 | 1125 | ||
1129 | if (symbol_conf.event_group && perf_evsel__is_group_leader(evsel)) | 1126 | if (perf_evsel__is_group_event(evsel)) |
1130 | width *= evsel->nr_members; | 1127 | width *= evsel->nr_members; |
1131 | 1128 | ||
1132 | printf(" %-*.*s| Source code & Disassembly of %s\n", | 1129 | printf(" %-*.*s| Source code & Disassembly of %s\n", |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 52021c3087df..bf758e53c929 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "xyarray.h" | 9 | #include "xyarray.h" |
10 | #include "cgroup.h" | 10 | #include "cgroup.h" |
11 | #include "hist.h" | 11 | #include "hist.h" |
12 | #include "symbol.h" | ||
12 | 13 | ||
13 | struct perf_counts_values { | 14 | struct perf_counts_values { |
14 | union { | 15 | union { |
@@ -246,11 +247,34 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) | |||
246 | return list_entry(evsel->node.next, struct perf_evsel, node); | 247 | return list_entry(evsel->node.next, struct perf_evsel, node); |
247 | } | 248 | } |
248 | 249 | ||
250 | /** | ||
251 | * perf_evsel__is_group_leader - Return whether given evsel is a leader event | ||
252 | * | ||
253 | * @evsel - evsel selector to be tested | ||
254 | * | ||
255 | * Return %true if @evsel is a group leader or a stand-alone event | ||
256 | */ | ||
249 | static inline bool perf_evsel__is_group_leader(const struct perf_evsel *evsel) | 257 | static inline bool perf_evsel__is_group_leader(const struct perf_evsel *evsel) |
250 | { | 258 | { |
251 | return evsel->leader == evsel; | 259 | return evsel->leader == evsel; |
252 | } | 260 | } |
253 | 261 | ||
262 | /** | ||
263 | * perf_evsel__is_group_event - Return whether given evsel is a group event | ||
264 | * | ||
265 | * @evsel - evsel selector to be tested | ||
266 | * | ||
267 | * Return %true iff event group view is enabled and @evsel is a actual group | ||
268 | * leader which has other members in the group | ||
269 | */ | ||
270 | static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel) | ||
271 | { | ||
272 | if (!symbol_conf.event_group) | ||
273 | return false; | ||
274 | |||
275 | return perf_evsel__is_group_leader(evsel) && evsel->nr_members > 1; | ||
276 | } | ||
277 | |||
254 | struct perf_attr_details { | 278 | struct perf_attr_details { |
255 | bool freq; | 279 | bool freq; |
256 | bool verbose; | 280 | bool verbose; |