aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-01-22 04:09:44 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-31 11:07:48 -0500
commit717e263fc354d53d0961e952b779d14a42c8ea66 (patch)
tree8bac96ac04d96d7544d9443fb29599480bb88a2f
parentfc24d7c25c9d880ae012548d522fe13caee556ed (diff)
perf report: Show group description when event group is enabled
When using event group viewer, it's better to show the group description rather than the leader information alone. If a leader did not contain any member, it's a non-group event. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> 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> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1358845787-1350-17-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-report.c15
-rw-r--r--tools/perf/ui/browsers/hists.c25
-rw-r--r--tools/perf/ui/gtk/hists.c14
-rw-r--r--tools/perf/util/evsel.c25
-rw-r--r--tools/perf/util/evsel.h8
5 files changed, 84 insertions, 3 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9cc768ecacad..ce518c48a525 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -299,6 +299,21 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
299 char unit; 299 char unit;
300 unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE]; 300 unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
301 u64 nr_events = self->stats.total_period; 301 u64 nr_events = self->stats.total_period;
302 struct perf_evsel *evsel = hists_to_evsel(self);
303 char buf[512];
304 size_t size = sizeof(buf);
305
306 if (symbol_conf.event_group && evsel->nr_members > 1) {
307 struct perf_evsel *pos;
308
309 perf_evsel__group_desc(evsel, buf, size);
310 evname = buf;
311
312 for_each_group_member(pos, evsel) {
313 nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
314 nr_events += pos->hists.stats.total_period;
315 }
316 }
302 317
303 nr_samples = convert_unit(nr_samples, &unit); 318 nr_samples = convert_unit(nr_samples, &unit);
304 ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit); 319 ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 167f7701f94e..20ccd57753f7 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1189,6 +1189,21 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
1189 const struct thread *thread = hists->thread_filter; 1189 const struct thread *thread = hists->thread_filter;
1190 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; 1190 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
1191 u64 nr_events = hists->stats.total_period; 1191 u64 nr_events = hists->stats.total_period;
1192 struct perf_evsel *evsel = hists_to_evsel(hists);
1193 char buf[512];
1194 size_t buflen = sizeof(buf);
1195
1196 if (symbol_conf.event_group && evsel->nr_members > 1) {
1197 struct perf_evsel *pos;
1198
1199 perf_evsel__group_desc(evsel, buf, buflen);
1200 ev_name = buf;
1201
1202 for_each_group_member(pos, evsel) {
1203 nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
1204 nr_events += pos->hists.stats.total_period;
1205 }
1206 }
1192 1207
1193 nr_samples = convert_unit(nr_samples, &unit); 1208 nr_samples = convert_unit(nr_samples, &unit);
1194 printed = scnprintf(bf, size, 1209 printed = scnprintf(bf, size,
@@ -1585,6 +1600,16 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
1585 ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : 1600 ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED :
1586 HE_COLORSET_NORMAL); 1601 HE_COLORSET_NORMAL);
1587 1602
1603 if (symbol_conf.event_group && evsel->nr_members > 1) {
1604 struct perf_evsel *pos;
1605
1606 ev_name = perf_evsel__group_name(evsel);
1607
1608 for_each_group_member(pos, evsel) {
1609 nr_events += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
1610 }
1611 }
1612
1588 nr_events = convert_unit(nr_events, &unit); 1613 nr_events = convert_unit(nr_events, &unit);
1589 printed = scnprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events, 1614 printed = scnprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events,
1590 unit, unit == ' ' ? "" : " ", ev_name); 1615 unit, unit == ' ' ? "" : " ", ev_name);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 9c02c4c0f3b7..1e764a8ad259 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -270,10 +270,18 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,
270 const char *evname = perf_evsel__name(pos); 270 const char *evname = perf_evsel__name(pos);
271 GtkWidget *scrolled_window; 271 GtkWidget *scrolled_window;
272 GtkWidget *tab_label; 272 GtkWidget *tab_label;
273 char buf[512];
274 size_t size = sizeof(buf);
273 275
274 if (symbol_conf.event_group && 276 if (symbol_conf.event_group) {
275 !perf_evsel__is_group_leader(pos)) 277 if (!perf_evsel__is_group_leader(pos))
276 continue; 278 continue;
279
280 if (pos->nr_members > 1) {
281 perf_evsel__group_desc(pos, buf, size);
282 evname = buf;
283 }
284 }
277 285
278 scrolled_window = gtk_scrolled_window_new(NULL, NULL); 286 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
279 287
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index baa26ddbcc7b..94e74043ded8 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -434,6 +434,31 @@ const char *perf_evsel__name(struct perf_evsel *evsel)
434 return evsel->name ?: "unknown"; 434 return evsel->name ?: "unknown";
435} 435}
436 436
437const char *perf_evsel__group_name(struct perf_evsel *evsel)
438{
439 return evsel->group_name ?: "anon group";
440}
441
442int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
443{
444 int ret;
445 struct perf_evsel *pos;
446 const char *group_name = perf_evsel__group_name(evsel);
447
448 ret = scnprintf(buf, size, "%s", group_name);
449
450 ret += scnprintf(buf + ret, size - ret, " { %s",
451 perf_evsel__name(evsel));
452
453 for_each_group_member(pos, evsel)
454 ret += scnprintf(buf + ret, size - ret, ", %s",
455 perf_evsel__name(pos));
456
457 ret += scnprintf(buf + ret, size - ret, " }");
458
459 return ret;
460}
461
437/* 462/*
438 * The enable_on_exec/disabled value strategy: 463 * The enable_on_exec/disabled value strategy:
439 * 464 *
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 371713977888..8512f6a8a6ea 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -114,6 +114,8 @@ extern const char *perf_evsel__sw_names[PERF_COUNT_SW_MAX];
114int __perf_evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, 114int __perf_evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result,
115 char *bf, size_t size); 115 char *bf, size_t size);
116const char *perf_evsel__name(struct perf_evsel *evsel); 116const char *perf_evsel__name(struct perf_evsel *evsel);
117const char *perf_evsel__group_name(struct perf_evsel *evsel);
118int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size);
117 119
118int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 120int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
119int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); 121int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
@@ -267,4 +269,10 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
267{ 269{
268 return evsel->idx - evsel->leader->idx; 270 return evsel->idx - evsel->leader->idx;
269} 271}
272
273#define for_each_group_member(_evsel, _leader) \
274for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \
275 (_evsel) && (_evsel)->leader == (_leader); \
276 (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
277
270#endif /* __PERF_EVSEL_H */ 278#endif /* __PERF_EVSEL_H */