All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andi Kleen <ak@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 13/15] perf hists browser: Zoom in/out for processor socket
Date: Fri,  4 Sep 2015 22:06:41 -0300	[thread overview]
Message-ID: <1441415203-7484-14-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1441415203-7484-1-git-send-email-acme@kernel.org>

From: Kan Liang <kan.liang@intel.com>

Currently, users can zoom in/out for threads and dso in 'perf top' and
'perf report'.

This patch extends it for the processor sockets.

'S' is the short key to zoom into current Processor Socket.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1441377946-44429-4-git-send-email-kan.liang@intel.com
[ Made it elide the Socket column when zooming into it, just like with the other zoom ops,
  make it use browser->pstack, to unzoom level by level ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 55 +++++++++++++++++++++++++++++++++++++++---
 tools/perf/util/hist.c         | 19 +++++++++++++++
 tools/perf/util/hist.h         |  1 +
 3 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 457f24c8fbe0..e4fd40f72b4a 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1429,6 +1429,7 @@ struct popup_action {
 	struct thread 		*thread;
 	struct dso		*dso;
 	struct map_symbol 	ms;
+	int			socket;
 
 	int (*fn)(struct hist_browser *browser, struct popup_action *act);
 };
@@ -1676,6 +1677,41 @@ add_exit_opt(struct hist_browser *browser __maybe_unused,
 	return 1;
 }
 
+static int
+do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
+{
+	if (browser->hists->socket_filter > -1) {
+		pstack__remove(browser->pstack, &browser->hists->socket_filter);
+		browser->hists->socket_filter = -1;
+		perf_hpp__set_elide(HISTC_SOCKET, false);
+	} else {
+		browser->hists->socket_filter = act->socket;
+		perf_hpp__set_elide(HISTC_SOCKET, true);
+		pstack__push(browser->pstack, &browser->hists->socket_filter);
+	}
+
+	hists__filter_by_socket(browser->hists);
+	hist_browser__reset(browser);
+	return 0;
+}
+
+static int
+add_socket_opt(struct hist_browser *browser, struct popup_action *act,
+	       char **optstr, int socket)
+{
+	if (socket < 0)
+		return 0;
+
+	if (asprintf(optstr, "Zoom %s Processor Socket %d",
+		     (browser->hists->socket_filter > -1) ? "out of" : "into",
+		     socket) < 0)
+		return 0;
+
+	act->socket = socket;
+	act->fn = do_zoom_socket;
+	return 1;
+}
+
 static void hist_browser__update_nr_entries(struct hist_browser *hb)
 {
 	u64 nr_entries = 0;
@@ -1729,6 +1765,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	"E             Expand all callchains\n"				\
 	"F             Toggle percentage of filtered entries\n"		\
 	"H             Display column headers\n"			\
+	"S             Zoom into current Processor Socket\n"		\
 
 	/* help messages are sorted by lexical order of the hotkey */
 	const char report_help[] = HIST_BROWSER_HELP_COMMON
@@ -1759,7 +1796,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 		hist_browser__update_nr_entries(browser);
 	}
 
-	browser->pstack = pstack__new(2);
+	browser->pstack = pstack__new(3);
 	if (browser->pstack == NULL)
 		goto out;
 
@@ -1778,6 +1815,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 		struct thread *thread = NULL;
 		struct dso *dso = NULL;
 		int choice = 0;
+		int socket = -1;
 
 		nr_options = 0;
 
@@ -1786,6 +1824,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 		if (browser->he_selection != NULL) {
 			thread = hist_browser__selected_thread(browser);
 			dso = browser->selection->map ? browser->selection->map->dso : NULL;
+			socket = browser->he_selection->socket;
 		}
 		switch (key) {
 		case K_TAB:
@@ -1828,6 +1867,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 			actions->thread = thread;
 			do_zoom_thread(browser, actions);
 			continue;
+		case 'S':
+			actions->socket = socket;
+			do_zoom_socket(browser, actions);
+			continue;
 		case '/':
 			if (ui_browser__input_window("Symbol to show",
 					"Please enter the name of symbol you want to see",
@@ -1903,9 +1946,11 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				 * Ditto for thread below.
 				 */
 				do_zoom_dso(browser, actions);
-			}
-			if (top == &browser->hists->thread_filter)
+			} else if (top == &browser->hists->thread_filter) {
 				do_zoom_thread(browser, actions);
+			} else if (top == &browser->hists->socket_filter) {
+				do_zoom_socket(browser, actions);
+			}
 			continue;
 		}
 		case 'q':
@@ -1973,7 +2018,9 @@ skip_annotation:
 		nr_options += add_map_opt(browser, &actions[nr_options],
 					  &options[nr_options],
 					  browser->selection->map);
-
+		nr_options += add_socket_opt(browser, &actions[nr_options],
+					     &options[nr_options],
+					     socket);
 		/* perf script support */
 		if (browser->he_selection) {
 			nr_options += add_script_opt(browser,
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 58687a10e03f..67b48616ab31 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1309,6 +1309,25 @@ static bool hists__filter_entry_by_socket(struct hists *hists,
 	return false;
 }
 
+void hists__filter_by_socket(struct hists *hists)
+{
+	struct rb_node *nd;
+
+	hists->stats.nr_non_filtered_samples = 0;
+
+	hists__reset_filter_stats(hists);
+	hists__reset_col_len(hists);
+
+	for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
+		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+
+		if (hists__filter_entry_by_socket(hists, h))
+			continue;
+
+		hists__remove_entry_filter(hists, h, HIST_FILTER__SOCKET);
+	}
+}
+
 void events_stats__inc(struct events_stats *stats, u32 type)
 {
 	++stats->nr_events[0];
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ef682f210923..4d6aa1dbdaee 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -147,6 +147,7 @@ size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp);
 void hists__filter_by_dso(struct hists *hists);
 void hists__filter_by_thread(struct hists *hists);
 void hists__filter_by_symbol(struct hists *hists);
+void hists__filter_by_socket(struct hists *hists);
 
 static inline bool hists__has_filter(struct hists *hists)
 {
-- 
2.1.0


  parent reply	other threads:[~2015-09-05  1:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-05  1:06 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 01/15] perf tests: Take into account address of each objdump line Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 02/15] perf tests: Make objdump disassemble zero blocks Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 03/15] perf tests: Stop reading if objdump output crossed sections Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 04/15] perf tests: Print objdump/dso buffers if they don't match Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 05/15] tools lib api fs: Make tracing_path_strerror_open message generic Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 06/15] tools lib api fs: Replace debugfs/tracefs objects interface with fs.c Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 07/15] tools lib api fs: Remove debugfs, tracefs and findfs objects Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 08/15] perf tools: Switch to tracing_path interface on appropriate places Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 09/15] perf test: Add entry to test cpu topology Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 10/15] perf tools: Add processor socket info to hist_entry and addr_location Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 11/15] perf tools: Introduce new sort type "socket" for the processor socket Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 12/15] perf report: Introduce --socket-filter option Arnaldo Carvalho de Melo
2015-09-05  1:06 ` Arnaldo Carvalho de Melo [this message]
2015-09-05  1:06 ` [PATCH 14/15] perf test: Add entry for hists socket filter Arnaldo Carvalho de Melo
2015-09-05  1:06 ` [PATCH 15/15] perf stat: Move sw clock metrics printout to stat-shadow Arnaldo Carvalho de Melo
2015-09-08 14:09 ` [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-09-08 14:21   ` Ingo Molnar
2015-09-08 14:30     ` Arnaldo Carvalho de Melo
2015-09-14  8:41       ` Ingo Molnar
2015-09-14  9:07         ` Wangnan (F)

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=1441415203-7484-14-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /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 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.