Re: [PATCH v3 3/4] perf util: Flexible to set block info output formats
From: Jiri Olsa
Date: Mon Jan 13 2020 - 05:10:49 EST
On Wed, Jan 08, 2020 at 07:03:53AM +0800, Jin Yao wrote:
SNIP
> int report__browse_block_hists(struct block_hist *bh, float min_percent,
> struct evsel *evsel, struct perf_env *env,
> - struct annotation_options *annotation_opts)
> + struct annotation_options *annotation_opts,
> + bool release)
> {
> int ret;
>
> @@ -451,13 +477,17 @@ int report__browse_block_hists(struct block_hist *bh, float min_percent,
> symbol_conf.report_individual_block = true;
> hists__fprintf(&bh->block_hists, true, 0, 0, min_percent,
> stdout, true);
> - hists__delete_entries(&bh->block_hists);
> + if (release)
> + hists__delete_entries(&bh->block_hists);
> +
> return 0;
> case 1:
> symbol_conf.report_individual_block = true;
> ret = block_hists_tui_browse(bh, evsel, min_percent,
> env, annotation_opts);
> - hists__delete_entries(&bh->block_hists);
> + if (release)
> + hists__delete_entries(&bh->block_hists);
> +
> return ret;
> default:
> return -1;
> diff --git a/tools/perf/util/block-info.h b/tools/perf/util/block-info.h
> index bfa22c59195d..0bf01e3a423d 100644
> --- a/tools/perf/util/block-info.h
> +++ b/tools/perf/util/block-info.h
> @@ -44,7 +44,8 @@ enum {
> struct block_report {
> struct block_hist hist;
> u64 cycles;
> - struct block_fmt fmts[PERF_HPP_REPORT__BLOCK_MAX_INDEX];
> + struct block_fmt *fmts;
hum, couldn't you just keep the array and use it instead of allocating it?
it will never be bigger than PERF_HPP_REPORT__BLOCK_MAX_INDEX, no?
we could get rid of that release code
jirka