linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
	mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
	kan.liang@intel.com, yao.jin@intel.com,
	Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH 2/2] perf top: support hotkey to change sort order
Date: Fri, 20 Mar 2020 15:24:14 +0800	[thread overview]
Message-ID: <20200320072414.25551-2-yao.jin@linux.intel.com> (raw)
In-Reply-To: <20200320072414.25551-1-yao.jin@linux.intel.com>

It would be nice if we can use a hotkey in perf top browser to
select a event for sorting.

For example,
perf top --group -e cycles,instructions,cache-misses

Samples
                Overhead  Shared Object             Symbol
  40.03%  45.71%   0.03%  div                       [.] main
  20.46%  14.67%   0.21%  libc-2.27.so              [.] __random_r
  20.01%  19.54%   0.02%  libc-2.27.so              [.] __random
   9.68%  10.68%   0.00%  div                       [.] compute_flag
   4.32%   4.70%   0.00%  libc-2.27.so              [.] rand
   3.84%   3.43%   0.00%  div                       [.] rand@plt
   0.05%   0.05%   2.33%  libc-2.27.so              [.] __strcmp_sse2_unaligned
   0.04%   0.08%   2.43%  perf                      [.] perf_hpp__is_dynamic_en
   0.04%   0.02%   6.64%  perf                      [.] rb_next
   0.04%   0.01%   3.87%  perf                      [.] dso__find_symbol
   0.04%   0.04%   1.77%  perf                      [.] sort__dso_cmp

When user press hotkey '2' (event index, starting from 0), it indicates
to sort output by the third event in group (cache-misses).

Samples
                Overhead  Shared Object               Symbol
   4.07%   1.28%   6.68%  perf                        [.] rb_next
   3.57%   3.98%   4.11%  perf                        [.] __hists__insert_output
   3.67%  11.24%   3.60%  perf                        [.] perf_hpp__is_dynamic_e
   3.67%   3.20%   3.20%  perf                        [.] hpp__sort_overhead
   0.81%   0.06%   3.01%  perf                        [.] dso__find_symbol
   1.62%   5.47%   2.51%  perf                        [.] hists__match
   2.70%   1.86%   2.47%  libc-2.27.so                [.] _int_malloc
   0.19%   0.00%   2.29%  [kernel]                    [k] copy_page
   0.41%   0.32%   1.98%  perf                        [.] hists__decay_entries
   1.84%   3.67%   1.68%  perf                        [.] sort__dso_cmp
   0.16%   0.00%   1.63%  [kernel]                    [k] clear_page_erms

Now the output is sorted by cache-misses.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/builtin-top.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 144043637cec..b39f6ffb874e 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -616,6 +616,7 @@ static void *display_thread_tui(void *arg)
 		.arg		= top,
 		.refresh	= top->delay_secs,
 	};
+	int ret;
 
 	/* In order to read symbols from other namespaces perf to  needs to call
 	 * setns(2).  This isn't permitted if the struct_fs has multiple users.
@@ -626,6 +627,7 @@ static void *display_thread_tui(void *arg)
 
 	prctl(PR_SET_NAME, "perf-top-UI", 0, 0, 0);
 
+repeat:
 	perf_top__sort_new_samples(top);
 
 	/*
@@ -638,13 +640,17 @@ static void *display_thread_tui(void *arg)
 		hists->uid_filter_str = top->record_opts.target.uid_str;
 	}
 
-	perf_evlist__tui_browse_hists(top->evlist, help, &hbt,
+	ret = perf_evlist__tui_browse_hists(top->evlist, help, &hbt,
 				      top->min_percent,
 				      &top->session->header.env,
 				      !top->record_opts.overwrite,
 				      &top->annotation_opts);
 
-	stop_top();
+	if (ret == K_RELOAD)
+		goto repeat;
+	else
+		stop_top();
+
 	return NULL;
 }
 
-- 
2.17.1


  reply	other threads:[~2020-03-20  7:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20  7:24 [PATCH 1/2] perf top: Support --group-sort-idx to change the sort order Jin Yao
2020-03-20  7:24 ` Jin Yao [this message]
2020-03-20 13:51   ` [PATCH 2/2] perf top: support hotkey to change " Arnaldo Carvalho de Melo
2020-03-22  3:46     ` Jin, Yao

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=20200320072414.25551-2-yao.jin@linux.intel.com \
    --to=yao.jin@linux.intel.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 \
    /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;
as well as URLs for NNTP newsgroup(s).