linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] perf tools: Add sort__has_comm variable
@ 2016-03-09 14:20 Namhyung Kim
  2016-03-09 14:20 ` [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Namhyung Kim @ 2016-03-09 14:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

The sort__has_comm variable is to check whether the comm sort key is
given.  This is necessary to support thread filtering in the TUI hists
browser later.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 3 +++
 tools/perf/util/sort.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 84c6654b4065..ca23b3ba0b2f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -27,6 +27,7 @@ int		sort__has_sym = 0;
 int		sort__has_dso = 0;
 int		sort__has_socket = 0;
 int		sort__has_thread = 0;
+int		sort__has_comm = 0;
 enum sort_mode	sort__mode = SORT_MODE__NORMAL;
 
 /*
@@ -2255,6 +2256,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 			sort__has_socket = 1;
 		} else if (sd->entry == &sort_thread) {
 			sort__has_thread = 1;
+		} else if (sd->entry == &sort_comm) {
+			sort__has_comm = 1;
 		}
 
 		return __sort_dimension__add(sd, level);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 151afc1b6c2f..3f4e35998119 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -37,6 +37,7 @@ extern int sort__has_parent;
 extern int sort__has_sym;
 extern int sort__has_socket;
 extern int sort__has_thread;
+extern int sort__has_comm;
 extern enum sort_mode sort__mode;
 extern struct sort_entry sort_comm;
 extern struct sort_entry sort_dso;
-- 
2.7.2

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

* [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key
  2016-03-09 14:20 [PATCH 1/3] perf tools: Add sort__has_comm variable Namhyung Kim
@ 2016-03-09 14:20 ` Namhyung Kim
  2016-03-09 14:26   ` Arnaldo Carvalho de Melo
  2016-03-09 14:20 ` [PATCH 3/3] perf hists browser: Check sort keys before hot key actions Namhyung Kim
  2016-03-11  8:50 ` [tip:perf/core] perf tools: Add sort__has_comm variable tip-bot for Namhyung Kim
  2 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2016-03-09 14:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

The commit 2eafd410e669 ("perf hists browser: Only 'Zoom into thread'
only when sort order has 'pid'") disabled thread filtering in hist
browser for the default sort key.  However the he->thread is still valid
even if 'pid' sort key is not given.  Only thing it should not use is
the pid (or tid) of the thread.  So allow to filter by thread when
'comm' sort key is given and show pid only if 'pid' sort key is given.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index aed9c8f011f7..69b0d23ffaaa 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2136,11 +2136,17 @@ static int hists__browser_title(struct hists *hists,
 	if (hists->uid_filter_str)
 		printed += snprintf(bf + printed, size - printed,
 				    ", UID: %s", hists->uid_filter_str);
-	if (thread)
-		printed += scnprintf(bf + printed, size - printed,
+	if (thread) {
+		if (sort__has_thread)
+			printed += scnprintf(bf + printed, size - printed,
 				    ", Thread: %s(%d)",
 				     (thread->comm_set ? thread__comm_str(thread) : ""),
 				    thread->tid);
+		else
+			printed += scnprintf(bf + printed, size - printed,
+				    ", Thread: %s",
+				     (thread->comm_set ? thread__comm_str(thread) : ""));
+	}
 	if (dso)
 		printed += scnprintf(bf + printed, size - printed,
 				    ", DSO: %s", dso->short_name);
@@ -2321,9 +2327,14 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 		thread__zput(browser->hists->thread_filter);
 		ui_helpline__pop();
 	} else {
-		ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
-				   thread->comm_set ? thread__comm_str(thread) : "",
-				   thread->tid);
+		if (sort__has_thread)
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "",
+					   thread->tid);
+		else
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "");
+
 		browser->hists->thread_filter = thread__get(thread);
 		perf_hpp__set_elide(HISTC_THREAD, false);
 		pstack__push(browser->pstack, &browser->hists->thread_filter);
@@ -2338,13 +2349,21 @@ static int
 add_thread_opt(struct hist_browser *browser, struct popup_action *act,
 	       char **optstr, struct thread *thread)
 {
-	if (!sort__has_thread || thread == NULL)
+	int ret;
+
+	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
 		return 0;
 
-	if (asprintf(optstr, "Zoom %s %s(%d) thread",
-		     browser->hists->thread_filter ? "out of" : "into",
-		     thread->comm_set ? thread__comm_str(thread) : "",
-		     thread->tid) < 0)
+	if (sort__has_thread)
+		ret = asprintf(optstr, "Zoom %s %s(%d) thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "",
+			       thread->tid);
+	else
+		ret = asprintf(optstr, "Zoom %s %s thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "");
+	if (ret < 0)
 		return 0;
 
 	act->thread = thread;
-- 
2.7.2

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

* [PATCH 3/3] perf hists browser: Check sort keys before hot key actions
  2016-03-09 14:20 [PATCH 1/3] perf tools: Add sort__has_comm variable Namhyung Kim
  2016-03-09 14:20 ` [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key Namhyung Kim
@ 2016-03-09 14:20 ` Namhyung Kim
  2016-03-11  8:51   ` [tip:perf/core] " tip-bot for Namhyung Kim
  2016-03-11  8:50 ` [tip:perf/core] perf tools: Add sort__has_comm variable tip-bot for Namhyung Kim
  2 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2016-03-09 14:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

The context menu in TUI hists browser checks corresponding sort keys
when creating the menu item.  But hotkey actions lacks these checks so
it can filter using incorrect info.

For example, default sort key of 'perf top' doesn't contain 'comm' or
'pid' sort key so each hist entry's thread info is not reliable.  Thus
it should prohibit using thread filter on 't' key.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 69b0d23ffaaa..fff17c77e250 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2321,6 +2321,9 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 {
 	struct thread *thread = act->thread;
 
+	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
+		return 0;
+
 	if (browser->hists->thread_filter) {
 		pstack__remove(browser->pstack, &browser->hists->thread_filter);
 		perf_hpp__set_elide(HISTC_THREAD, false);
@@ -2376,6 +2379,9 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
 {
 	struct map *map = act->ms.map;
 
+	if (!sort__has_dso || map == NULL)
+		return 0;
+
 	if (browser->hists->dso_filter) {
 		pstack__remove(browser->pstack, &browser->hists->dso_filter);
 		perf_hpp__set_elide(HISTC_DSO, false);
@@ -2527,6 +2533,9 @@ add_exit_opt(struct hist_browser *browser __maybe_unused,
 static int
 do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
 {
+	if (!sort__has_socket || act->socket < 0)
+		return 0;
+
 	if (browser->hists->socket_filter > -1) {
 		pstack__remove(browser->pstack, &browser->hists->socket_filter);
 		browser->hists->socket_filter = -1;
-- 
2.7.2

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

* Re: [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key
  2016-03-09 14:20 ` [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key Namhyung Kim
@ 2016-03-09 14:26   ` Arnaldo Carvalho de Melo
  2016-03-09 15:14     ` [PATCH v2 " Namhyung Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-03-09 14:26 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

Em Wed, Mar 09, 2016 at 11:20:52PM +0900, Namhyung Kim escreveu:
> The commit 2eafd410e669 ("perf hists browser: Only 'Zoom into thread'
> only when sort order has 'pid'") disabled thread filtering in hist
> browser for the default sort key.  However the he->thread is still valid
> even if 'pid' sort key is not given.  Only thing it should not use is
> the pid (or tid) of the thread.  So allow to filter by thread when
> 'comm' sort key is given and show pid only if 'pid' sort key is given.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/ui/browsers/hists.c | 39 +++++++++++++++++++++++++++++----------
>  1 file changed, 29 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index aed9c8f011f7..69b0d23ffaaa 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -2136,11 +2136,17 @@ static int hists__browser_title(struct hists *hists,
>  	if (hists->uid_filter_str)
>  		printed += snprintf(bf + printed, size - printed,
>  				    ", UID: %s", hists->uid_filter_str);
> -	if (thread)
> -		printed += scnprintf(bf + printed, size - printed,
> +	if (thread) {
> +		if (sort__has_thread)

Please use { } for multi-line if blocks.

> +			printed += scnprintf(bf + printed, size - printed,
>  				    ", Thread: %s(%d)",
>  				     (thread->comm_set ? thread__comm_str(thread) : ""),
>  				    thread->tid);
> +		else
> +			printed += scnprintf(bf + printed, size - printed,
> +				    ", Thread: %s",
> +				     (thread->comm_set ? thread__comm_str(thread) : ""));
> +	}
>  	if (dso)
>  		printed += scnprintf(bf + printed, size - printed,
>  				    ", DSO: %s", dso->short_name);
> @@ -2321,9 +2327,14 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
>  		thread__zput(browser->hists->thread_filter);
>  		ui_helpline__pop();
>  	} else {
> -		ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
> -				   thread->comm_set ? thread__comm_str(thread) : "",
> -				   thread->tid);
> +		if (sort__has_thread)
> +			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
> +					   thread->comm_set ? thread__comm_str(thread) : "",
> +					   thread->tid);
> +		else
> +			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s thread\"",
> +					   thread->comm_set ? thread__comm_str(thread) : "");
> +
>  		browser->hists->thread_filter = thread__get(thread);
>  		perf_hpp__set_elide(HISTC_THREAD, false);
>  		pstack__push(browser->pstack, &browser->hists->thread_filter);
> @@ -2338,13 +2349,21 @@ static int
>  add_thread_opt(struct hist_browser *browser, struct popup_action *act,
>  	       char **optstr, struct thread *thread)
>  {
> -	if (!sort__has_thread || thread == NULL)
> +	int ret;
> +
> +	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
>  		return 0;
>  
> -	if (asprintf(optstr, "Zoom %s %s(%d) thread",
> -		     browser->hists->thread_filter ? "out of" : "into",
> -		     thread->comm_set ? thread__comm_str(thread) : "",
> -		     thread->tid) < 0)
> +	if (sort__has_thread)

Ditto

> +		ret = asprintf(optstr, "Zoom %s %s(%d) thread",
> +			       browser->hists->thread_filter ? "out of" : "into",
> +			       thread->comm_set ? thread__comm_str(thread) : "",
> +			       thread->tid);
> +	else

ditto

> +		ret = asprintf(optstr, "Zoom %s %s thread",
> +			       browser->hists->thread_filter ? "out of" : "into",
> +			       thread->comm_set ? thread__comm_str(thread) : "");
> +	if (ret < 0)
>  		return 0;
>  
>  	act->thread = thread;
> -- 
> 2.7.2

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

* [PATCH v2 2/3] perf hists browser: Allow thread filtering for comm sort key
  2016-03-09 14:26   ` Arnaldo Carvalho de Melo
@ 2016-03-09 15:14     ` Namhyung Kim
  2016-03-11  8:51       ` [tip:perf/core] " tip-bot for Namhyung Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2016-03-09 15:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

The commit 2eafd410e669 ("perf hists browser: Only 'Zoom into thread'
only when sort order has 'pid'") disabled thread filtering in hist
browser for the default sort key.  However the he->thread is still valid
even if 'pid' sort key is not given.  Only thing it should not use is
the pid (or tid) of the thread.  So allow to filter by thread when
'comm' sort key is given and show pid only if 'pid' sort key is given.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index aed9c8f011f7..cb4191bf6cec 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2136,11 +2136,18 @@ static int hists__browser_title(struct hists *hists,
 	if (hists->uid_filter_str)
 		printed += snprintf(bf + printed, size - printed,
 				    ", UID: %s", hists->uid_filter_str);
-	if (thread)
-		printed += scnprintf(bf + printed, size - printed,
+	if (thread) {
+		if (sort__has_thread) {
+			printed += scnprintf(bf + printed, size - printed,
 				    ", Thread: %s(%d)",
 				     (thread->comm_set ? thread__comm_str(thread) : ""),
 				    thread->tid);
+		} else {
+			printed += scnprintf(bf + printed, size - printed,
+				    ", Thread: %s",
+				     (thread->comm_set ? thread__comm_str(thread) : ""));
+		}
+	}
 	if (dso)
 		printed += scnprintf(bf + printed, size - printed,
 				    ", DSO: %s", dso->short_name);
@@ -2321,9 +2328,15 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 		thread__zput(browser->hists->thread_filter);
 		ui_helpline__pop();
 	} else {
-		ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
-				   thread->comm_set ? thread__comm_str(thread) : "",
-				   thread->tid);
+		if (sort__has_thread) {
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "",
+					   thread->tid);
+		} else {
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "");
+		}
+
 		browser->hists->thread_filter = thread__get(thread);
 		perf_hpp__set_elide(HISTC_THREAD, false);
 		pstack__push(browser->pstack, &browser->hists->thread_filter);
@@ -2338,13 +2351,22 @@ static int
 add_thread_opt(struct hist_browser *browser, struct popup_action *act,
 	       char **optstr, struct thread *thread)
 {
-	if (!sort__has_thread || thread == NULL)
+	int ret;
+
+	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
 		return 0;
 
-	if (asprintf(optstr, "Zoom %s %s(%d) thread",
-		     browser->hists->thread_filter ? "out of" : "into",
-		     thread->comm_set ? thread__comm_str(thread) : "",
-		     thread->tid) < 0)
+	if (sort__has_thread) {
+		ret = asprintf(optstr, "Zoom %s %s(%d) thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "",
+			       thread->tid);
+	} else {
+		ret = asprintf(optstr, "Zoom %s %s thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "");
+	}
+	if (ret < 0)
 		return 0;
 
 	act->thread = thread;
-- 
2.7.2

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

* [tip:perf/core] perf tools: Add sort__has_comm variable
  2016-03-09 14:20 [PATCH 1/3] perf tools: Add sort__has_comm variable Namhyung Kim
  2016-03-09 14:20 ` [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key Namhyung Kim
  2016-03-09 14:20 ` [PATCH 3/3] perf hists browser: Check sort keys before hot key actions Namhyung Kim
@ 2016-03-11  8:50 ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-03-11  8:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, tglx, namhyung, linux-kernel, jolsa, acme, hpa, dsahern

Commit-ID:  078b8d4a406fa8ce4a3c9d5145c27be1ed2b1dfd
Gitweb:     http://git.kernel.org/tip/078b8d4a406fa8ce4a3c9d5145c27be1ed2b1dfd
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 9 Mar 2016 23:20:51 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 10 Mar 2016 16:47:19 -0300

perf tools: Add sort__has_comm variable

The sort__has_comm variable is to check whether the comm sort key is
given.  This is necessary to support thread filtering in the TUI hists
browser later.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1457533253-21419-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 3 +++
 tools/perf/util/sort.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index ced849e..93fa136 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -27,6 +27,7 @@ int		sort__has_sym = 0;
 int		sort__has_dso = 0;
 int		sort__has_socket = 0;
 int		sort__has_thread = 0;
+int		sort__has_comm = 0;
 enum sort_mode	sort__mode = SORT_MODE__NORMAL;
 
 /*
@@ -2262,6 +2263,8 @@ static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
 			sort__has_socket = 1;
 		} else if (sd->entry == &sort_thread) {
 			sort__has_thread = 1;
+		} else if (sd->entry == &sort_comm) {
+			sort__has_comm = 1;
 		}
 
 		return __sort_dimension__add(sd, list, level);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 151afc1..3f4e359 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -37,6 +37,7 @@ extern int sort__has_parent;
 extern int sort__has_sym;
 extern int sort__has_socket;
 extern int sort__has_thread;
+extern int sort__has_comm;
 extern enum sort_mode sort__mode;
 extern struct sort_entry sort_comm;
 extern struct sort_entry sort_dso;

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

* [tip:perf/core] perf hists browser: Allow thread filtering for comm sort key
  2016-03-09 15:14     ` [PATCH v2 " Namhyung Kim
@ 2016-03-11  8:51       ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-03-11  8:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, peterz, mingo, namhyung, jolsa, tglx, acme, hpa, dsahern

Commit-ID:  6962ccb37b50366014074aec6fd14497cf719642
Gitweb:     http://git.kernel.org/tip/6962ccb37b50366014074aec6fd14497cf719642
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 10 Mar 2016 00:14:50 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 10 Mar 2016 16:47:37 -0300

perf hists browser: Allow thread filtering for comm sort key

The commit 2eafd410e669 ("perf hists browser: Only 'Zoom into thread'
only when sort order has 'pid'") disabled thread filtering in hist
browser for the default sort key.  However the he->thread is still valid
even if 'pid' sort key is not given.  Only thing it should not use is
the pid (or tid) of the thread.  So allow to filter by thread when
'comm' sort key is given and show pid only if 'pid' sort key is given.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1457536490-24084-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index aed9c8f..cb4191b 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2136,11 +2136,18 @@ static int hists__browser_title(struct hists *hists,
 	if (hists->uid_filter_str)
 		printed += snprintf(bf + printed, size - printed,
 				    ", UID: %s", hists->uid_filter_str);
-	if (thread)
-		printed += scnprintf(bf + printed, size - printed,
+	if (thread) {
+		if (sort__has_thread) {
+			printed += scnprintf(bf + printed, size - printed,
 				    ", Thread: %s(%d)",
 				     (thread->comm_set ? thread__comm_str(thread) : ""),
 				    thread->tid);
+		} else {
+			printed += scnprintf(bf + printed, size - printed,
+				    ", Thread: %s",
+				     (thread->comm_set ? thread__comm_str(thread) : ""));
+		}
+	}
 	if (dso)
 		printed += scnprintf(bf + printed, size - printed,
 				    ", DSO: %s", dso->short_name);
@@ -2321,9 +2328,15 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 		thread__zput(browser->hists->thread_filter);
 		ui_helpline__pop();
 	} else {
-		ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
-				   thread->comm_set ? thread__comm_str(thread) : "",
-				   thread->tid);
+		if (sort__has_thread) {
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "",
+					   thread->tid);
+		} else {
+			ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s thread\"",
+					   thread->comm_set ? thread__comm_str(thread) : "");
+		}
+
 		browser->hists->thread_filter = thread__get(thread);
 		perf_hpp__set_elide(HISTC_THREAD, false);
 		pstack__push(browser->pstack, &browser->hists->thread_filter);
@@ -2338,13 +2351,22 @@ static int
 add_thread_opt(struct hist_browser *browser, struct popup_action *act,
 	       char **optstr, struct thread *thread)
 {
-	if (!sort__has_thread || thread == NULL)
+	int ret;
+
+	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
 		return 0;
 
-	if (asprintf(optstr, "Zoom %s %s(%d) thread",
-		     browser->hists->thread_filter ? "out of" : "into",
-		     thread->comm_set ? thread__comm_str(thread) : "",
-		     thread->tid) < 0)
+	if (sort__has_thread) {
+		ret = asprintf(optstr, "Zoom %s %s(%d) thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "",
+			       thread->tid);
+	} else {
+		ret = asprintf(optstr, "Zoom %s %s thread",
+			       browser->hists->thread_filter ? "out of" : "into",
+			       thread->comm_set ? thread__comm_str(thread) : "");
+	}
+	if (ret < 0)
 		return 0;
 
 	act->thread = thread;

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

* [tip:perf/core] perf hists browser: Check sort keys before hot key actions
  2016-03-09 14:20 ` [PATCH 3/3] perf hists browser: Check sort keys before hot key actions Namhyung Kim
@ 2016-03-11  8:51   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-03-11  8:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, dsahern, hpa, peterz, namhyung, linux-kernel, jolsa, tglx, mingo

Commit-ID:  599a2f38a989a79df99838f22cb607f5e2b5b56c
Gitweb:     http://git.kernel.org/tip/599a2f38a989a79df99838f22cb607f5e2b5b56c
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 9 Mar 2016 23:20:53 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 10 Mar 2016 16:48:02 -0300

perf hists browser: Check sort keys before hot key actions

The context menu in TUI hists browser checks corresponding sort keys
when creating the menu item.  But hotkey actions lacks these checks so
it can filter using incorrect info.

For example, default sort key of 'perf top' doesn't contain 'comm' or
'pid' sort key so each hist entry's thread info is not reliable.  Thus
it should prohibit using thread filter on 't' key.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1457533253-21419-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cb4191b..4b98165 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2322,6 +2322,9 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act)
 {
 	struct thread *thread = act->thread;
 
+	if ((!sort__has_thread && !sort__has_comm) || thread == NULL)
+		return 0;
+
 	if (browser->hists->thread_filter) {
 		pstack__remove(browser->pstack, &browser->hists->thread_filter);
 		perf_hpp__set_elide(HISTC_THREAD, false);
@@ -2379,6 +2382,9 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
 {
 	struct map *map = act->ms.map;
 
+	if (!sort__has_dso || map == NULL)
+		return 0;
+
 	if (browser->hists->dso_filter) {
 		pstack__remove(browser->pstack, &browser->hists->dso_filter);
 		perf_hpp__set_elide(HISTC_DSO, false);
@@ -2530,6 +2536,9 @@ add_exit_opt(struct hist_browser *browser __maybe_unused,
 static int
 do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
 {
+	if (!sort__has_socket || act->socket < 0)
+		return 0;
+
 	if (browser->hists->socket_filter > -1) {
 		pstack__remove(browser->pstack, &browser->hists->socket_filter);
 		browser->hists->socket_filter = -1;

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

end of thread, other threads:[~2016-03-11  8:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-09 14:20 [PATCH 1/3] perf tools: Add sort__has_comm variable Namhyung Kim
2016-03-09 14:20 ` [PATCH 2/3] perf hists browser: Allow thread filtering for comm sort key Namhyung Kim
2016-03-09 14:26   ` Arnaldo Carvalho de Melo
2016-03-09 15:14     ` [PATCH v2 " Namhyung Kim
2016-03-11  8:51       ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-03-09 14:20 ` [PATCH 3/3] perf hists browser: Check sort keys before hot key actions Namhyung Kim
2016-03-11  8:51   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-03-11  8:50 ` [tip:perf/core] perf tools: Add sort__has_comm variable tip-bot for Namhyung Kim

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).