Re: [PATCH 07/14] perf ui/hist: Add support for event group view

From: Jiri Olsa
Date: Tue Dec 18 2012 - 10:47:12 EST


On Mon, Dec 17, 2012 at 03:38:58PM +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@xxxxxxx>
>
> Show group members' overhead also when showing the leader's if event
> group is enabled. Use macro for defining hpp functions which looks
> almost identical.

SNIP

> -
> -static int hpp__color_overhead_us(struct perf_hpp_fmt *fmt __maybe_unused,
> - struct perf_hpp *hpp, struct hist_entry *he)
> +static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he,
> + u64 (*get_field)(struct hist_entry *),
> + const char *fmt, hpp_snprint_fn print_fn)

it's hard to tell from diff, but the function looks like this (group part):

if (symbol_conf.event_group) {
int prev_idx, idx_delta, i;
struct perf_evsel *evsel = hists_to_evsel(hists);
struct hist_entry *pair;
int nr_members = evsel->nr_members;

if (nr_members <= 1)
return ret;

prev_idx = perf_evsel__group_idx(evsel);

list_for_each_entry(pair, &he->pairs.head, pairs.node) {
u64 period = get_field(pair);
u64 total = pair->hists->stats.total_period;

if (!total)
continue;

evsel = hists_to_evsel(pair->hists);
idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1;

for (i = 0; i < idx_delta; i++) {
ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 0.0);
}

ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 100.0 * period / total);

prev_idx += 1 + idx_delta;
}

idx_delta = nr_members - prev_idx - 1;

for (i = 0; i < idx_delta; i++) {
ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 0.0);
}
}

The temporary array (initial send) was more clear to me.. but if
this is the preffered way I wont object, since this is another place
that would benefit from hist_entries array linking.. when (and if)
there's ever patch for that ;-)

I think this code now suffers from mischosen data layer

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/