Commit 2bcf7306 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf annotate: Loop group events directly in annotation__calc_percent()

We need to bring in 'struct hists' object and for that we need 'struct
perf_evsel' object in the scope.

Switching the group data loop with the evsel group loop.  It does the
same thing, but it brings evsel object, that we can use later get the
'struct hists' object.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20180804130521.11408-8-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 48a1e4f2
...@@ -1774,13 +1774,14 @@ static void calc_percent(struct sym_hist *sym_hist, ...@@ -1774,13 +1774,14 @@ static void calc_percent(struct sym_hist *sym_hist,
} }
static void annotation__calc_percent(struct annotation *notes, static void annotation__calc_percent(struct annotation *notes,
struct perf_evsel *evsel, s64 len) struct perf_evsel *leader, s64 len)
{ {
struct annotation_line *al, *next; struct annotation_line *al, *next;
struct perf_evsel *evsel;
list_for_each_entry(al, &notes->src->source, node) { list_for_each_entry(al, &notes->src->source, node) {
s64 end; s64 end;
int i; int i = 0;
if (al->offset == -1) if (al->offset == -1)
continue; continue;
...@@ -1788,12 +1789,14 @@ static void annotation__calc_percent(struct annotation *notes, ...@@ -1788,12 +1789,14 @@ static void annotation__calc_percent(struct annotation *notes,
next = annotation_line__next(al, &notes->src->source); next = annotation_line__next(al, &notes->src->source);
end = next ? next->offset : len; end = next ? next->offset : len;
for (i = 0; i < al->data_nr; i++) { for_each_group_evsel(evsel, leader) {
struct annotation_data *data; struct annotation_data *data;
struct sym_hist *sym_hist; struct sym_hist *sym_hist;
sym_hist = annotation__histogram(notes, evsel->idx + i); BUG_ON(i >= al->data_nr);
data = &al->data[i];
sym_hist = annotation__histogram(notes, evsel->idx);
data = &al->data[i++];
calc_percent(sym_hist, data, al->offset, end); calc_percent(sym_hist, data, al->offset, end);
} }
......
...@@ -452,11 +452,18 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel) ...@@ -452,11 +452,18 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
return evsel->idx - evsel->leader->idx; return evsel->idx - evsel->leader->idx;
} }
/* Iterates group WITHOUT the leader. */
#define for_each_group_member(_evsel, _leader) \ #define for_each_group_member(_evsel, _leader) \
for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \ for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \
(_evsel) && (_evsel)->leader == (_leader); \ (_evsel) && (_evsel)->leader == (_leader); \
(_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node)) (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
/* Iterates group WITH the leader. */
#define for_each_group_evsel(_evsel, _leader) \
for ((_evsel) = _leader; \
(_evsel) && (_evsel)->leader == (_leader); \
(_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel) static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel)
{ {
return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK; return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
......
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