From: Jiri Olsa <jolsa@redhat.com>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com
Subject: Re: [PATCH v6 7/7] perf report: Sort by sampled cycles percent per block for tui
Date: Wed, 6 Nov 2019 22:01:06 +0100 [thread overview]
Message-ID: <20191106210106.GA12156@krava> (raw)
In-Reply-To: <20191105033611.25493-8-yao.jin@linux.intel.com>
On Tue, Nov 05, 2019 at 11:36:11AM +0800, Jin Yao wrote:
SNIP
>
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
> tools/perf/builtin-report.c | 27 ++++++++++++---
> tools/perf/ui/browsers/hists.c | 62 +++++++++++++++++++++++++++++++++-
> tools/perf/ui/browsers/hists.h | 2 ++
> tools/perf/util/block-info.c | 12 +++++++
> tools/perf/util/block-info.h | 3 ++
> tools/perf/util/hist.h | 12 +++++++
> 6 files changed, 112 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 7a8b0be8f09a..af5a57d06f12 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -485,6 +485,22 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
> return ret + fprintf(fp, "\n#\n");
> }
>
> +static int perf_evlist__tui_block_hists_browse(struct evlist *evlist,
> + struct report *rep)
> +{
> + struct evsel *pos;
> + int i = 0, ret;
> +
> + evlist__for_each_entry(evlist, pos) {
> + ret = report__tui_browse_block_hists(&rep->block_reports[i++].hist,
> + rep->min_percent, pos);
> + if (ret != 0)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static int perf_evlist__tty_browse_hists(struct evlist *evlist,
> struct report *rep,
> const char *help)
> @@ -595,6 +611,11 @@ static int report__browse_hists(struct report *rep)
>
> switch (use_browser) {
> case 1:
> + if (rep->total_cycles_mode) {
> + ret = perf_evlist__tui_block_hists_browse(evlist, rep);
> + break;
> + }
it's good that most of it is in the block-info.c,
however what I mean was to have a single report
function for rep->total_cycles_mode, like:
report__browse_block_hists()
{
switch (use_browser) {
case 1:
ret = perf_evlist__tui_block_hists_browse(evlist, rep);
break;
case 0:
ret = perf_evlist__tty_block_hists_browse(evlist, rep);
break;
...
}
preferable in block-info.c as well
which would be hooked in report__browse_hists:
report__browse_hists()
{
if (rep->total_cycles_mode)
return report__browse_block_hists();
...
}
plus below
SNIP
> +
> +static int block_hists_browser__title(struct hist_browser *browser, char *bf,
> + size_t size)
> +{
> + struct hists *hists = evsel__hists(browser->block_evsel);
> + const char *evname = perf_evsel__name(browser->block_evsel);
> + unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
> + int ret;
> +
> + ret = scnprintf(bf, size, "# Samples: %lu", nr_samples);
> + if (evname)
> + scnprintf(bf + ret, size - ret, " of event '%s'", evname);
> +
> + return 0;
> +}
> +
> +int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
> + float min_percent)
> +{
> + struct hists *hists = &bh->block_hists;
> + struct hist_browser *browser;
> + int key = -1;
> + static const char help[] =
> + " q Quit \n";
> +
> + browser = hist_browser__new(hists);
> + if (!browser)
> + return -1;
> +
> + browser->block_evsel = evsel;
> + browser->title = block_hists_browser__title;
> + browser->min_pcnt = min_percent;
> +
> + /* reset abort key so that it can get Ctrl-C as a key */
> + SLang_reset_tty();
> + SLang_init_tty(0, 0, 0);
> +
> + while (1) {
> + key = hist_browser__run(browser, "? - help", true);
> +
> + switch (key) {
> + case 'q':
> + goto out;
> + case '?':
> + ui_browser__help_window(&browser->b, help);
> + break;
> + default:
> + break;
> + }
> + }
> +
> +out:
> + hist_browser__delete(browser);
> + return 0;
> +}
also could this go to block-info.c as well?
thanks,
jirka
next prev parent reply other threads:[~2019-11-06 21:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 3:36 [PATCH v6 0/7] perf report: Support sorting all blocks by cycles Jin Yao
2019-11-05 3:36 ` [PATCH v6 1/7] perf diff: Don't use hack to skip column length calculation Jin Yao
2019-11-05 3:36 ` [PATCH v6 2/7] perf util: Cleanup and refactor block info functions Jin Yao
2019-11-05 3:36 ` [PATCH v6 3/7] perf util: Count the total cycles of all samples Jin Yao
2019-11-05 3:36 ` [PATCH v6 4/7] perf util: Support block formats with compare/sort/display Jin Yao
2019-11-05 3:36 ` [PATCH v6 5/7] perf report: Sort by sampled cycles percent per block for stdio Jin Yao
2019-11-05 3:36 ` [PATCH v6 6/7] perf report: Support --percent-limit for --total-cycles Jin Yao
2019-11-05 3:36 ` [PATCH v6 7/7] perf report: Sort by sampled cycles percent per block for tui Jin Yao
2019-11-06 21:01 ` Jiri Olsa [this message]
2019-11-07 6:19 ` Jin, Yao
2019-11-07 9:26 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191106210106.GA12156@krava \
--to=jolsa@redhat.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
--cc=yao.jin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox