Re: [PATCH v5 5/7] perf report: Sort by sampled cycles percent per block for stdio

From: Jiri Olsa
Date: Mon Nov 04 2019 - 09:04:49 EST


On Wed, Oct 30, 2019 at 02:04:28PM +0800, Jin Yao wrote:

SNIP

> +static int hists__fprintf_all_blocks(struct block_hist *bh)
> +{
> + symbol_conf.report_individual_block = true;
> + hists__fprintf(&bh->block_hists, true, 0, 0, 0,
> + stdout, true);
> + hists__delete_entries(&bh->block_hists);
> + return 0;
> +}
> +
> static int perf_evlist__tty_browse_hists(struct evlist *evlist,
> struct report *rep,
> const char *help)
> {
> struct evsel *pos;
> + int i = 0;
>
> if (!quiet) {
> fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
> @@ -494,12 +509,20 @@ static int perf_evlist__tty_browse_hists(struct evlist *evlist,
> evlist__for_each_entry(evlist, pos) {
> struct hists *hists = evsel__hists(pos);
> const char *evname = perf_evsel__name(pos);
> + struct block_hist *block_hist;
>
> if (symbol_conf.event_group &&
> !perf_evsel__is_group_leader(pos))
> continue;
>
> hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
> +
> + if (rep->total_cycles_mode) {
> + block_hist = &rep->block_reports[i++].hist;
> + hists__fprintf_all_blocks(block_hist);
> + continue;
> + }

hum, you don't need evsel in here, please make separate function like
perf_evlist__tty_browse_block_hists, where you will iterate directly
block_reports[i++]

IMO the best would be to have report__browse_block_hists in block-info.c
and handle all display modes from there

that's probably the last thing that would be moved to block-info.c
other than that I think the patchset is ok

thanks,
jirka