public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kan.liang@intel.com
To: acme@kernel.org
Cc: a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org,
	namhyung@kernel.org, ak@linux.intel.com, eranian@google.com,
	linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>
Subject: [PATCH RFC 03/10] perf,tools: support option --socket
Date: Tue, 18 Aug 2015 05:25:39 -0400	[thread overview]
Message-ID: <1439889946-28986-4-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1439889946-28986-1-git-send-email-kan.liang@intel.com>

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

Introduce a new option for perf report to show the event information in
the same socket together.
When this option is set, perf report will force to sort by socket.

$ perf report --stdio --socket
 # To display the perf.data header info, please use
 --header/--header-only options.
 #
 #
 # Total Lost Samples: 0
 #
 # Samples: 686  of event 'cycles'
 # Event count (approx.): 349215462
 #
 #
 # Socket: 0
 #
 # Overhead  Command    Shared Object     Symbol
 # ........  .........  ................
 .................................
 #
    97.05%  test       test              [.] plusB_c
     0.98%  test       test              [.] plusA_c
     0.16%  test       [kernel.vmlinux]  [k] add_mm_counter_fast
     0.15%  swapper    [kernel.vmlinux]  [k] note_gp_changes
     0.15%  perf       [kernel.vmlinux]  [k] unmap_single_vma
     0.06%  perf       [kernel.vmlinux]  [k] run_timer_softirq
     0.00%  swapper    [kernel.vmlinux]  [k] native_write_msr
 #
 # Socket: 1
 #
 # Overhead  Command    Shared Object     Symbol
 # ........  .........  ................
 .................................
 #
     0.93%  perf       [kernel.vmlinux]  [k] smp_call_function_single
     0.19%  perf       [kernel.vmlinux]  [k] page_fault
     0.19%  swapper    [kernel.vmlinux]  [k] pm_qos_request
     0.12%  rcu_sched  [kernel.vmlinux]  [k]
dyntick_save_progress_counter
     0.00%  swapper    [kernel.vmlinux]  [k] wake_up_process
     0.00%  swapper    [kernel.vmlinux]  [k] __do_softirq
     0.00%  swapper    [kernel.vmlinux]  [k] run_timer_softirq
     0.00%  swapper    [kernel.vmlinux]  [k] native_write_msr
     0.00%  perf       [kernel.vmlinux]  [k] native_write_msr

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/Documentation/perf-report.txt |  3 +++
 tools/perf/builtin-diff.c                |  2 +-
 tools/perf/builtin-report.c              | 17 ++++++++++++++++-
 tools/perf/builtin-top.c                 |  2 +-
 tools/perf/ui/stdio/hist.c               | 14 ++++++++++----
 tools/perf/util/cpumap.c                 | 14 ++++++++++++++
 tools/perf/util/cpumap.h                 |  2 ++
 tools/perf/util/hist.h                   |  2 +-
 tools/perf/util/sort.c                   |  6 ++++++
 tools/perf/util/symbol.h                 |  1 +
 10 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index ca76b0d..49a42e4 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -293,6 +293,9 @@ OPTIONS
 --group::
 	Show event group information together.
 
+--socket::
+	Show event information in the same socket together.
+
 --demangle::
 	Demangle symbol names to human readable form. It's enabled by default,
 	disable with --no-demangle.
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 0b180a8..0dfd91f 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -667,7 +667,7 @@ static void hists__process(struct hists *hists)
 	hists__precompute(hists);
 	hists__output_resort(hists, NULL);
 
-	hists__fprintf(hists, true, 0, 0, 0, stdout);
+	hists__fprintf(hists, true, 0, 0, 0, stdout, -1);
 }
 
 static void data__fprintf(void)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 62b285e..6fdf9f4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -345,7 +345,17 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 			continue;
 
 		hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
-		hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout);
+
+		if (symbol_conf.socket) {
+			int i;
+
+			for (i = 0; i < max_socket_num; i++) {
+				fprintf(stdout, "#\n# Socket: %d\n#\n", i);
+				hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout, i);
+			}
+		} else
+			hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout, -1);
+
 		fprintf(stdout, "\n\n");
 	}
 
@@ -724,6 +734,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Show a column with the sum of periods"),
 	OPT_BOOLEAN(0, "group", &symbol_conf.event_group,
 		    "Show event group information together"),
+	OPT_BOOLEAN(0, "socket", &symbol_conf.socket,
+		    "Show event information in the same socket together"),
 	OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "",
 		    "use branch records for per branch histogram filling",
 		    parse_branch_mode),
@@ -909,6 +921,9 @@ repeat:
 
 	sort__setup_elide(stdout);
 
+	if (symbol_conf.socket)
+		set_max_socket_num();
+
 	ret = __cmd_report(&report);
 	if (ret == K_SWITCH_INPUT_DATA) {
 		perf_session__delete(session);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index bfe24f1..deffe44 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -295,7 +295,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
 	hists__output_recalc_col_len(hists, top->print_entries - printed);
 	putchar('\n');
 	hists__fprintf(hists, false, top->print_entries - printed, win_width,
-		       top->min_percent, stdout);
+		       top->min_percent, stdout, -1);
 }
 
 static void prompt_integer(int *target, const char *msg)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index dfcbc90..2f512b8 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -323,7 +323,8 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
 		return 0;
 
 	perf_hpp__for_each_format(fmt) {
-		if (perf_hpp__should_skip(fmt))
+		if (perf_hpp__should_skip(fmt) ||
+		    !strcmp(fmt->name, "SOCKET"))
 			continue;
 
 		/*
@@ -371,7 +372,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
 }
 
 size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
-		      int max_cols, float min_pcnt, FILE *fp)
+		      int max_cols, float min_pcnt, FILE *fp, int socket)
 {
 	struct perf_hpp_fmt *fmt;
 	struct rb_node *nd;
@@ -402,7 +403,8 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 	fprintf(fp, "# ");
 
 	perf_hpp__for_each_format(fmt) {
-		if (perf_hpp__should_skip(fmt))
+		if (perf_hpp__should_skip(fmt) ||
+		    !strcmp(fmt->name, "SOCKET"))
 			continue;
 
 		if (!first)
@@ -428,7 +430,8 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 	perf_hpp__for_each_format(fmt) {
 		unsigned int i;
 
-		if (perf_hpp__should_skip(fmt))
+		if (perf_hpp__should_skip(fmt) ||
+		    !strcmp(fmt->name, "SOCKET"))
 			continue;
 
 		if (!first)
@@ -465,6 +468,9 @@ print_entries:
 		if (h->filtered)
 			continue;
 
+		if ((socket >= 0) && (cpu__get_socket(h->cpu) != socket))
+			continue;
+
 		percent = hist_entry__get_percent_limit(h);
 		if (percent < min_pcnt)
 			continue;
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 7f25e6c..ae03426 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -407,6 +407,20 @@ out:
 		pr_err("Failed to read max cpus, using default of %d\n", max_cpu_num);
 }
 
+void set_max_socket_num(void)
+{
+	int cpu, socket;
+
+	set_max_cpu_num();
+
+	max_socket_num = 1;
+	for (cpu = 0; cpu < max_cpu_num; cpu++) {
+		socket = cpu__get_socket(cpu);
+		if (max_socket_num < (socket + 1))
+			max_socket_num = socket + 1;
+	}
+}
+
 /* Determine highest possible node in the system for sparse allocation */
 static void set_max_node_num(void)
 {
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index effb56e..094edd9 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -56,9 +56,11 @@ static inline bool cpu_map__empty(const struct cpu_map *map)
 
 int max_cpu_num;
 int max_node_num;
+int max_socket_num;
 int *cpunode_map;
 
 int cpu__setup_cpunode_map(void);
+void set_max_socket_num(void);
 
 static inline int cpu__max_node(void)
 {
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index af80fb5..b188a62 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -139,7 +139,7 @@ void events_stats__inc(struct events_stats *stats, u32 type);
 size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
 
 size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
-		      int max_cols, float min_pcnt, FILE *fp);
+		      int max_cols, float min_pcnt, FILE *fp, int socket);
 size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp);
 
 void hists__filter_by_dso(struct hists *hists);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 245e254..70f0526 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1930,6 +1930,12 @@ int setup_sorting(void)
 			return err;
 	}
 
+	if (symbol_conf.socket) {
+		err = sort_dimension__add("socket");
+		if (err < 0)
+			return err;
+	}
+
 	reset_dimensions();
 
 	/*
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index a4cde92..7c153c7 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -101,6 +101,7 @@ struct symbol_conf {
 			annotate_asm_raw,
 			annotate_src,
 			event_group,
+			socket,
 			demangle,
 			demangle_kernel,
 			filter_relative,
-- 
1.8.3.1


  parent reply	other threads:[~2015-08-18 16:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18  9:25 [PATCH RFC 00/10] stat read during perf sampling kan.liang
2015-08-18  9:25 ` [PATCH RFC 01/10] perf,tools: open event on evsel cpus and threads kan.liang
2015-08-20  8:57   ` Jiri Olsa
2015-08-20 17:24     ` Liang, Kan
2015-08-21  7:43       ` Jiri Olsa
2015-08-21 13:24         ` Liang, Kan
2015-08-18  9:25 ` [PATCH RFC 02/10] perf,tools: Support new sort type --socket kan.liang
2015-08-20  9:09   ` Jiri Olsa
2015-08-21 20:25     ` Liang, Kan
2015-08-23 22:00       ` Jiri Olsa
2015-08-24 14:22         ` Liang, Kan
2015-08-24 14:27           ` Jiri Olsa
2015-08-24 16:47             ` Liang, Kan
2015-08-24 19:30               ` Jiri Olsa
2015-08-27 18:24                 ` Jiri Olsa
2015-08-27 18:29                   ` Liang, Kan
2015-08-18  9:25 ` kan.liang [this message]
2015-08-18 17:36   ` [PATCH RFC 03/10] perf,tools: support option --socket Stephane Eranian
2015-08-20  9:30   ` Jiri Olsa
2015-08-18  9:25 ` [PATCH RFC 04/10] perf,tools: Add 'N' event/group modifier kan.liang
2015-08-18  9:25 ` [PATCH RFC 05/10] perf,tools: Enable statistic read for perf record kan.liang
2015-08-20  9:39   ` Jiri Olsa
2015-08-20  9:41   ` Jiri Olsa
2015-08-18  9:25 ` [PATCH RFC 06/10] perf,tools: New RECORD type PERF_RECORD_STAT_READ kan.liang
2015-08-20  9:49   ` Jiri Olsa
2015-08-18  9:25 ` [PATCH RFC 07/10] perf,tools: record counter statistics during sampling kan.liang
2015-08-18  9:25 ` [PATCH RFC 08/10] perf,tools: option to set stat read interval kan.liang
2015-08-18  9:25 ` [PATCH RFC 09/10] perf,tools: don't validate non-sample event kan.liang
2015-08-18  9:25 ` [PATCH RFC 10/10] perf,tools: Show STAT_READ in perf report kan.liang

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=1439889946-28986-4-git-send-email-kan.liang@intel.com \
    --to=kan.liang@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox