All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] perf top: Support --group-sort-idx to change the sort order
@ 2020-03-24 22:07 Jin Yao
  2020-03-24 22:07 ` [PATCH v2 2/2] perf top: support hotkey to change " Jin Yao
  2020-04-04  8:41 ` [tip: perf/urgent] perf top: Support --group-sort-idx to change the " tip-bot2 for Jin Yao
  0 siblings, 2 replies; 6+ messages in thread
From: Jin Yao @ 2020-03-24 22:07 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

perf report has supported the option --group-sort-idx, which
sorts the output by the event at the index n in event group.

For example,
perf record -e cycles,instructions,cache-misses
perf report --group --group-sort-idx 2 --stdio

The perf-report output is sorted by cache-misses.

This patch supports --group-sort-idx in perf-top.

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

The perf-top output is sorted by cache-misses.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/Documentation/perf-top.txt | 5 +++++
 tools/perf/builtin-top.c              | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 324b6b53c86b..0e97dcef794d 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -53,6 +53,11 @@ Default is to monitor all CPUS.
 --group::
         Put the counters into a counter group.
 
+--group-sort-idx::
+	Sort the output by the event at the index n in group. If n is invalid,
+	sort by the first event. It can support multiple groups with different
+	amount of events. WARNING: This should be used on grouped events.
+
 -F <freq>::
 --freq=<freq>::
 	Profile at this frequency. Use 'max' to use the currently maximum
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index d2539b793f9d..494c7b9a1022 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1545,6 +1545,10 @@ int cmd_top(int argc, const char **argv)
 			"number of thread to run event synthesize"),
 	OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces,
 		    "Record namespaces events"),
+	OPT_INTEGER(0, "group-sort-idx", &symbol_conf.group_sort_idx,
+		    "Sort the output by the event at the index n in group. "
+		    "If n is invalid, sort by the first event. "
+		    "WARNING: should be used on grouped events."),
 	OPTS_EVSWITCH(&top.evswitch),
 	OPT_END()
 	};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] perf top: support hotkey to change sort order
  2020-03-24 22:07 [PATCH v2 1/2] perf top: Support --group-sort-idx to change the sort order Jin Yao
@ 2020-03-24 22:07 ` Jin Yao
  2020-03-30  0:43   ` Jin, Yao
  2020-04-04  8:41   ` [tip: perf/urgent] perf top: Support " tip-bot2 for Jin Yao
  2020-04-04  8:41 ` [tip: perf/urgent] perf top: Support --group-sort-idx to change the " tip-bot2 for Jin Yao
  1 sibling, 2 replies; 6+ messages in thread
From: Jin Yao @ 2020-03-24 22:07 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

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.

 v2:
 ---
 Zero the history if hotkey is pressed.

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

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 494c7b9a1022..29ddae7e1805 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,18 @@ 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) {
+		top->zero = true;
+		goto repeat;
+	} else
+		stop_top();
+
 	return NULL;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] perf top: support hotkey to change sort order
  2020-03-24 22:07 ` [PATCH v2 2/2] perf top: support hotkey to change " Jin Yao
@ 2020-03-30  0:43   ` Jin, Yao
  2020-03-30 15:26     ` Arnaldo Carvalho de Melo
  2020-04-04  8:41   ` [tip: perf/urgent] perf top: Support " tip-bot2 for Jin Yao
  1 sibling, 1 reply; 6+ messages in thread
From: Jin, Yao @ 2020-03-30  0:43 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin

Hi Arnaldo,

The v2 patch zeros the history when pressing the hotkey. Is it OK?

Thanks
Jin Yao

On 3/25/2020 6:07 AM, Jin Yao wrote:
> 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.
> 
>   v2:
>   ---
>   Zero the history if hotkey is pressed.
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>   tools/perf/builtin-top.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 494c7b9a1022..29ddae7e1805 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,18 @@ 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) {
> +		top->zero = true;
> +		goto repeat;
> +	} else
> +		stop_top();
> +
>   	return NULL;
>   }
>   
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] perf top: support hotkey to change sort order
  2020-03-30  0:43   ` Jin, Yao
@ 2020-03-30 15:26     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-03-30 15:26 UTC (permalink / raw)
  To: Jin, Yao
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

Em Mon, Mar 30, 2020 at 08:43:47AM +0800, Jin, Yao escreveu:
> Hi Arnaldo,
> 
> The v2 patch zeros the history when pressing the hotkey. Is it OK?

Yeah, I've applied it to my perf/core branch.

Thanks,

- Arnaldo
 
> Thanks
> Jin Yao
> 
> On 3/25/2020 6:07 AM, Jin Yao wrote:
> > 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.
> > 
> >   v2:
> >   ---
> >   Zero the history if hotkey is pressed.
> > 
> > Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> > ---
> >   tools/perf/builtin-top.c | 11 +++++++++--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> > index 494c7b9a1022..29ddae7e1805 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,18 @@ 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) {
> > +		top->zero = true;
> > +		goto repeat;
> > +	} else
> > +		stop_top();
> > +
> >   	return NULL;
> >   }
> > 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: perf/urgent] perf top: Support hotkey to change sort order
  2020-03-24 22:07 ` [PATCH v2 2/2] perf top: support hotkey to change " Jin Yao
  2020-03-30  0:43   ` Jin, Yao
@ 2020-04-04  8:41   ` tip-bot2 for Jin Yao
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Jin Yao @ 2020-04-04  8:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jin Yao, Arnaldo Carvalho de Melo, Alexander Shishkin,
	Andi Kleen, Jin Yao, Jiri Olsa, Kan Liang, Peter Zijlstra, x86,
	LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     2605af0f32d1bf434dd6819732c7851a97f5cbc0
Gitweb:        https://git.kernel.org/tip/2605af0f32d1bf434dd6819732c7851a97f5cbc0
Author:        Jin Yao <yao.jin@linux.intel.com>
AuthorDate:    Wed, 25 Mar 2020 06:07:11 +08:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 03 Apr 2020 09:37:55 -03:00

perf top: Support hotkey to change sort order

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.

 v2:
 ---
 Zero the history if hotkey is pressed.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200324220711.6025-2-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-top.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 9ff7943..289cf83 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,18 @@ 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) {
+		top->zero = true;
+		goto repeat;
+	} else
+		stop_top();
+
 	return NULL;
 }
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip: perf/urgent] perf top: Support --group-sort-idx to change the sort order
  2020-03-24 22:07 [PATCH v2 1/2] perf top: Support --group-sort-idx to change the sort order Jin Yao
  2020-03-24 22:07 ` [PATCH v2 2/2] perf top: support hotkey to change " Jin Yao
@ 2020-04-04  8:41 ` tip-bot2 for Jin Yao
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Jin Yao @ 2020-04-04  8:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jin Yao, Arnaldo Carvalho de Melo, Alexander Shishkin,
	Andi Kleen, Jin Yao, Jiri Olsa, Kan Liang, Peter Zijlstra, x86,
	LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     df7deb2cceef0546ab2115702da3421b7c61a8c0
Gitweb:        https://git.kernel.org/tip/df7deb2cceef0546ab2115702da3421b7c61a8c0
Author:        Jin Yao <yao.jin@linux.intel.com>
AuthorDate:    Wed, 25 Mar 2020 06:07:10 +08:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 03 Apr 2020 09:37:55 -03:00

perf top: Support --group-sort-idx to change the sort order

'perf report' supports the option --group-sort-idx, which sorts the
output by the event at the index n in event group.

For example:

  perf record -e cycles,instructions,cache-misses
  perf report --group --group-sort-idx 2 --stdio

The perf-report output is sorted by cache-misses.

This patch supports --group-sort-idx in perf-top.

For example:

  perf top --group -e cycles,instructions,cache-misses --group-sort-idx 2

The perf-top output is sorted by cache-misses.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200324220711.6025-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-top.txt | 5 +++++
 tools/perf/builtin-top.c              | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index ddab103..487737a 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -53,6 +53,11 @@ Default is to monitor all CPUS.
 --group::
         Put the counters into a counter group.
 
+--group-sort-idx::
+	Sort the output by the event at the index n in group. If n is invalid,
+	sort by the first event. It can support multiple groups with different
+	amount of events. WARNING: This should be used on grouped events.
+
 -F <freq>::
 --freq=<freq>::
 	Profile at this frequency. Use 'max' to use the currently maximum
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 02ea2cf..9ff7943 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1560,6 +1560,10 @@ int cmd_top(int argc, const char **argv)
 		    "Record namespaces events"),
 	OPT_BOOLEAN(0, "all-cgroups", &opts->record_cgroup,
 		    "Record cgroup events"),
+	OPT_INTEGER(0, "group-sort-idx", &symbol_conf.group_sort_idx,
+		    "Sort the output by the event at the index n in group. "
+		    "If n is invalid, sort by the first event. "
+		    "WARNING: should be used on grouped events."),
 	OPTS_EVSWITCH(&top.evswitch),
 	OPT_END()
 	};

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-04  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 22:07 [PATCH v2 1/2] perf top: Support --group-sort-idx to change the sort order Jin Yao
2020-03-24 22:07 ` [PATCH v2 2/2] perf top: support hotkey to change " Jin Yao
2020-03-30  0:43   ` Jin, Yao
2020-03-30 15:26     ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] perf top: Support " tip-bot2 for Jin Yao
2020-04-04  8:41 ` [tip: perf/urgent] perf top: Support --group-sort-idx to change the " tip-bot2 for Jin Yao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.