Commit 759ff497 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

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: default avatarNamhyung 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b1dd4432
...@@ -314,7 +314,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self, ...@@ -314,7 +314,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
char buf[512]; char buf[512];
size_t size = sizeof(buf); size_t size = sizeof(buf);
if (symbol_conf.event_group && evsel->nr_members > 1) { if (perf_evsel__is_group_event(evsel)) {
struct perf_evsel *pos; struct perf_evsel *pos;
perf_evsel__group_desc(evsel, buf, size); perf_evsel__group_desc(evsel, buf, size);
......
...@@ -1193,7 +1193,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, ...@@ -1193,7 +1193,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
char buf[512]; char buf[512];
size_t buflen = sizeof(buf); size_t buflen = sizeof(buf);
if (symbol_conf.event_group && evsel->nr_members > 1) { if (perf_evsel__is_group_event(evsel)) {
struct perf_evsel *pos; struct perf_evsel *pos;
perf_evsel__group_desc(evsel, buf, buflen); perf_evsel__group_desc(evsel, buf, buflen);
...@@ -1709,7 +1709,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser, ...@@ -1709,7 +1709,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED :
HE_COLORSET_NORMAL); HE_COLORSET_NORMAL);
if (symbol_conf.event_group && evsel->nr_members > 1) { if (perf_evsel__is_group_event(evsel)) {
struct perf_evsel *pos; struct perf_evsel *pos;
ev_name = perf_evsel__group_name(evsel); ev_name = perf_evsel__group_name(evsel);
......
...@@ -32,21 +32,18 @@ static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -32,21 +32,18 @@ static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he,
int ret; int ret;
double percent = 0.0; double percent = 0.0;
struct hists *hists = he->hists; struct hists *hists = he->hists;
struct perf_evsel *evsel = hists_to_evsel(hists);
if (hists->stats.total_period) if (hists->stats.total_period)
percent = 100.0 * get_field(he) / hists->stats.total_period; percent = 100.0 * get_field(he) / hists->stats.total_period;
ret = __percent_color_snprintf(hpp->buf, hpp->size, percent); ret = __percent_color_snprintf(hpp->buf, hpp->size, percent);
if (symbol_conf.event_group) { if (perf_evsel__is_group_event(evsel)) {
int prev_idx, idx_delta; int prev_idx, idx_delta;
struct perf_evsel *evsel = hists_to_evsel(hists);
struct hist_entry *pair; struct hist_entry *pair;
int nr_members = evsel->nr_members; int nr_members = evsel->nr_members;
if (nr_members <= 1)
return ret;
prev_idx = perf_evsel__group_idx(evsel); prev_idx = perf_evsel__group_idx(evsel);
list_for_each_entry(pair, &he->pairs.head, pairs.node) { list_for_each_entry(pair, &he->pairs.head, pairs.node) {
......
...@@ -16,6 +16,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -16,6 +16,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
{ {
int ret; int ret;
struct hists *hists = he->hists; struct hists *hists = he->hists;
struct perf_evsel *evsel = hists_to_evsel(hists);
if (fmt_percent) { if (fmt_percent) {
double percent = 0.0; double percent = 0.0;
...@@ -28,15 +29,11 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -28,15 +29,11 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
} else } else
ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he)); ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he));
if (symbol_conf.event_group) { if (perf_evsel__is_group_event(evsel)) {
int prev_idx, idx_delta; int prev_idx, idx_delta;
struct perf_evsel *evsel = hists_to_evsel(hists);
struct hist_entry *pair; struct hist_entry *pair;
int nr_members = evsel->nr_members; int nr_members = evsel->nr_members;
if (nr_members <= 1)
return ret;
prev_idx = perf_evsel__group_idx(evsel); prev_idx = perf_evsel__group_idx(evsel);
list_for_each_entry(pair, &he->pairs.head, pairs.node) { list_for_each_entry(pair, &he->pairs.head, pairs.node) {
......
...@@ -649,9 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st ...@@ -649,9 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
next = disasm__get_next_ip_line(&notes->src->source, dl); next = disasm__get_next_ip_line(&notes->src->source, dl);
if (symbol_conf.event_group && if (perf_evsel__is_group_event(evsel)) {
perf_evsel__is_group_leader(evsel) &&
evsel->nr_members > 1) {
nr_percent = evsel->nr_members; nr_percent = evsel->nr_members;
ppercents = calloc(nr_percent, sizeof(double)); ppercents = calloc(nr_percent, sizeof(double));
if (ppercents == NULL) if (ppercents == NULL)
...@@ -721,8 +719,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st ...@@ -721,8 +719,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (queue) if (queue)
return -1; return -1;
if (symbol_conf.event_group && if (perf_evsel__is_group_event(evsel))
perf_evsel__is_group_leader(evsel))
width *= evsel->nr_members; width *= evsel->nr_members;
if (!*dl->line) if (!*dl->line)
...@@ -1126,7 +1123,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, ...@@ -1126,7 +1123,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
len = symbol__size(sym); len = symbol__size(sym);
namelen = strlen(d_filename); namelen = strlen(d_filename);
if (symbol_conf.event_group && perf_evsel__is_group_leader(evsel)) if (perf_evsel__is_group_event(evsel))
width *= evsel->nr_members; width *= evsel->nr_members;
printf(" %-*.*s| Source code & Disassembly of %s\n", printf(" %-*.*s| Source code & Disassembly of %s\n",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "xyarray.h" #include "xyarray.h"
#include "cgroup.h" #include "cgroup.h"
#include "hist.h" #include "hist.h"
#include "symbol.h"
struct perf_counts_values { struct perf_counts_values {
union { union {
...@@ -246,11 +247,34 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) ...@@ -246,11 +247,34 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
return list_entry(evsel->node.next, struct perf_evsel, node); return list_entry(evsel->node.next, struct perf_evsel, node);
} }
/**
* perf_evsel__is_group_leader - Return whether given evsel is a leader event
*
* @evsel - evsel selector to be tested
*
* Return %true if @evsel is a group leader or a stand-alone event
*/
static inline bool perf_evsel__is_group_leader(const struct perf_evsel *evsel) static inline bool perf_evsel__is_group_leader(const struct perf_evsel *evsel)
{ {
return evsel->leader == evsel; return evsel->leader == evsel;
} }
/**
* perf_evsel__is_group_event - Return whether given evsel is a group event
*
* @evsel - evsel selector to be tested
*
* Return %true iff event group view is enabled and @evsel is a actual group
* leader which has other members in the group
*/
static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel)
{
if (!symbol_conf.event_group)
return false;
return perf_evsel__is_group_leader(evsel) && evsel->nr_members > 1;
}
struct perf_attr_details { struct perf_attr_details {
bool freq; bool freq;
bool verbose; bool verbose;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment