Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1219341 > unrolled thread

[PATCH 1/5] perf,tools: add processor socket info in hist_entry and addr_location

Started bykan.liang@intel.com
First post2015-09-05 00:10 +0200
Last post2015-09-05 00:10 +0200
Articles 12 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/5] perf,tools: add processor socket info in hist_entry and addr_location kan.liang@intel.com - 2015-09-05 00:10 +0200
    Re: [PATCH 4/5] perf,tools: zoom in/out for processor socket Andi Kleen <ak@linux.intel.com> - 2015-09-05 00:10 +0200
    [PATCH 4/5] perf,tools: zoom in/out for processor socket kan.liang@intel.com - 2015-09-05 00:10 +0200
    [PATCH 2/5] perf,tools: Support new sort type --socket kan.liang@intel.com - 2015-09-05 00:10 +0200
      Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 00:50 +0200
        Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 01:00 +0200
          Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 01:10 +0200
            Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 01:30 +0200
              Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 01:40 +0200
            Re: [PATCH 2/5] perf,tools: Support new sort type --socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-05 01:30 +0200
    [PATCH 3/5] perf,report: introduce socket-filter option kan.liang@intel.com - 2015-09-05 00:10 +0200
    [PATCH 5/5] perf,test: test hists socket filter kan.liang@intel.com - 2015-09-05 00:10 +0200

#1219341 — [PATCH 1/5] perf,tools: add processor socket info in hist_entry and addr_location

Fromkan.liang@intel.com
Date2015-09-05 00:10 +0200
Subject[PATCH 1/5] perf,tools: add processor socket info in hist_entry and addr_location
Message-ID<q57lg-6z4-7@gated-at.bofh.it>
From: Kan Liang <kan.liang@intel.com>

Add processor socket id info in hist_entry and addr_location.
For perf report, the socket id info is from perf.data.
For others, the socket id info is from current system.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/builtin-report.c | 4 ++++
 tools/perf/util/event.c     | 1 +
 tools/perf/util/hist.c      | 1 +
 tools/perf/util/sort.h      | 1 +
 tools/perf/util/symbol.h    | 1 +
 5 files changed, 8 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 62b285e..affd70d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -149,6 +149,7 @@ static int process_sample_event(struct perf_tool *tool,
 		.add_entry_cb 		= hist_iter__report_callback,
 	};
 	int ret = 0;
+	struct perf_env *env = evsel->evlist->env;
 
 	if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
 		pr_debug("problem processing %d event, skipping it.\n",
@@ -156,6 +157,9 @@ static int process_sample_event(struct perf_tool *tool,
 		return -1;
 	}
 
+	/* read socket id from perf.data for perf report */
+	al.socket = env->cpu[al.cpu].socket_id;
+
 	if (rep->hide_unresolved && al.sym == NULL)
 		goto out_put;
 
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 7ff6127..0bf8c98 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1021,6 +1021,7 @@ int perf_event__preprocess_sample(const union perf_event *event,
 
 	al->sym = NULL;
 	al->cpu = sample->cpu;
+	al->socket = cpu_map__get_socket_id(al->cpu);
 
 	if (al->map) {
 		struct dso *dso = al->map->dso;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 08b6cd9..80c4683 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -452,6 +452,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
 			.map	= al->map,
 			.sym	= al->sym,
 		},
+		.socket	 = al->socket,
 		.cpu	 = al->cpu,
 		.cpumode = al->cpumode,
 		.ip	 = al->addr,
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 3c2a399..7cf1cf7 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -90,6 +90,7 @@ struct hist_entry {
 	struct comm		*comm;
 	u64			ip;
 	u64			transaction;
+	s32			socket;
 	s32			cpu;
 	u8			cpumode;
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 440ba8a..40073c6 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -191,6 +191,7 @@ struct addr_location {
 	u8	      filtered;
 	u8	      cpumode;
 	s32	      cpu;
+	s32	      socket;
 };
 
 struct symsrc {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1219343 — Re: [PATCH 4/5] perf,tools: zoom in/out for processor socket

FromAndi Kleen <ak@linux.intel.com>
Date2015-09-05 00:10 +0200
SubjectRe: [PATCH 4/5] perf,tools: zoom in/out for processor socket
Message-ID<q57lg-6z4-15@gated-at.bofh.it>
In reply to#1219341
On Fri, Sep 04, 2015 at 10:45:45AM -0400, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> Currently, users can zoom in/out for threads and dso in perf top and
> report. This patch extends it for socket.
> 'S' is the short key to zoom into current Processor Socket.

Nice feature.

Would be nice to also able to zoom into the current logical CPU.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219344 — [PATCH 4/5] perf,tools: zoom in/out for processor socket

Fromkan.liang@intel.com
Date2015-09-05 00:10 +0200
Subject[PATCH 4/5] perf,tools: zoom in/out for processor socket
Message-ID<q57lg-6z4-17@gated-at.bofh.it>
In reply to#1219341
From: Kan Liang <kan.liang@intel.com>

Currently, users can zoom in/out for threads and dso in perf top and
report. This patch extends it for socket.
'S' is the short key to zoom into current Processor Socket.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/ui/browsers/hists.c | 43 +++++++++++++++++++++++++++++++++++++++++-
 tools/perf/util/hist.c         | 19 +++++++++++++++++++
 tools/perf/util/hist.h         |  1 +
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 457f24c..d695fd2 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,37 @@ 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)
+		browser->hists->socket_filter = -1;
+	else
+		browser->hists->socket_filter = act->socket;
+
+	perf_hpp__set_elide(HISTC_SOCKET, false);
+	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 +1761,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
@@ -1778,6 +1811,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 +1820,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 +1863,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",
@@ -1973,7 +2012,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 d7e53c2..bb633cd 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1308,6 +1308,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 ef682f2..4d6aa1d 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)
 {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219345 — [PATCH 2/5] perf,tools: Support new sort type --socket

Fromkan.liang@intel.com
Date2015-09-05 00:10 +0200
Subject[PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q57lg-6z4-19@gated-at.bofh.it>
In reply to#1219341
From: Kan Liang <kan.liang@intel.com>

This patch enable perf report to sort by processor socket

$ perf report --stdio --sort socket,comm,dso,symbol
 # 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
 #
 # Overhead  SOCKET  Command    Shared Object     Symbol
 # ........  ......  .........  ................
 .................................
 #
    97.05%     000  test       test              [.] plusB_c
     0.98%     000  test       test              [.] plusA_c
     0.93%     001  perf       [kernel.vmlinux]  [k]
smp_call_function_single
     0.19%     001  perf       [kernel.vmlinux]  [k] page_fault
     0.19%     001  swapper    [kernel.vmlinux]  [k] pm_qos_request
     0.16%     000  test       [kernel.vmlinux]  [k] add_mm_counter_fast

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/Documentation/perf-report.txt |  3 ++-
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/sort.c                   | 22 ++++++++++++++++++++++
 tools/perf/util/sort.h                   |  1 +
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 9c7981b..92361a7 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -68,7 +68,7 @@ OPTIONS
 --sort=::
 	Sort histogram entries by given key(s) - multiple keys can be specified
 	in CSV format.  Following sort keys are available:
-	pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight.
+	pid, comm, dso, symbol, parent, cpu, socket, srcline, weight, local_weight.
 
 	Each key has following meaning:
 
@@ -79,6 +79,7 @@ OPTIONS
 	- parent: name of function matched to the parent regex filter. Unmatched
 	entries are displayed as "[other]".
 	- cpu: cpu number the task ran at the time of sample
+	- socket: processor socket number the task ran at the time of sample
 	- srcline: filename and line number executed at the time of sample.  The
 	DWARF debugging info must be provided.
 	- srcfile: file name of the source file of the same. Requires dwarf
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index de6d58e..5d04d28 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -29,6 +29,7 @@ enum hist_column {
 	HISTC_COMM,
 	HISTC_PARENT,
 	HISTC_CPU,
+	HISTC_SOCKET,
 	HISTC_SRCLINE,
 	HISTC_SRCFILE,
 	HISTC_MISPREDICT,
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index a97bcee..c4a32b9 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -421,6 +421,27 @@ struct sort_entry sort_cpu = {
 	.se_width_idx	= HISTC_CPU,
 };
 
+/* --sort socket */
+
+static int64_t
+sort__socket_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	return right->socket - left->socket;
+}
+
+static int hist_entry__socket_snprintf(struct hist_entry *he, char *bf,
+				    size_t size, unsigned int width)
+{
+	return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket);
+}
+
+struct sort_entry sort_socket = {
+	.se_header      = "SOCKET",
+	.se_cmp	        = sort__socket_cmp,
+	.se_snprintf    = hist_entry__socket_snprintf,
+	.se_width_idx	= HISTC_SOCKET,
+};
+
 /* sort keys for branch stacks */
 
 static int64_t
@@ -1248,6 +1269,7 @@ static struct sort_dimension common_sort_dimensions[] = {
 	DIM(SORT_SYM, "symbol", sort_sym),
 	DIM(SORT_PARENT, "parent", sort_parent),
 	DIM(SORT_CPU, "cpu", sort_cpu),
+	DIM(SORT_SOCKET, "socket", sort_socket),
 	DIM(SORT_SRCLINE, "srcline", sort_srcline),
 	DIM(SORT_SRCFILE, "srcfile", sort_srcfile),
 	DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 7cf1cf7..654ac8a 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -173,6 +173,7 @@ enum sort_type {
 	SORT_SYM,
 	SORT_PARENT,
 	SORT_CPU,
+	SORT_SOCKET,
 	SORT_SRCLINE,
 	SORT_SRCFILE,
 	SORT_LOCAL_WEIGHT,
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219364 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 00:50 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q57XZ-7hG-35@gated-at.bofh.it>
In reply to#1219345
Em Fri, Sep 04, 2015 at 10:45:43AM -0400, kan.liang@intel.com escreveu:
> From: Kan Liang <kan.liang@intel.com>
> 
> This patch enable perf report to sort by processor socket
> 
> $ perf report --stdio --sort socket,comm,dso,symbol
>  # 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
>  #
>  # Overhead  SOCKET  Command    Shared Object     Symbol
>  # ........  ......  .........  ................
>  .................................

So this works in 'perf top' only for the first screen rendering, when it
refreshes we lose the "SOCKET" header (why all caps?) and the colum
stops being %03d and instead becomes %d, I am checking now.

- Arnaldo

>  #
>     97.05%     000  test       test              [.] plusB_c
>      0.98%     000  test       test              [.] plusA_c
>      0.93%     001  perf       [kernel.vmlinux]  [k]
> smp_call_function_single
>      0.19%     001  perf       [kernel.vmlinux]  [k] page_fault
>      0.19%     001  swapper    [kernel.vmlinux]  [k] pm_qos_request
>      0.16%     000  test       [kernel.vmlinux]  [k] add_mm_counter_fast
> 
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
>  tools/perf/Documentation/perf-report.txt |  3 ++-
>  tools/perf/util/hist.h                   |  1 +
>  tools/perf/util/sort.c                   | 22 ++++++++++++++++++++++
>  tools/perf/util/sort.h                   |  1 +
>  4 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index 9c7981b..92361a7 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -68,7 +68,7 @@ OPTIONS
>  --sort=::
>  	Sort histogram entries by given key(s) - multiple keys can be specified
>  	in CSV format.  Following sort keys are available:
> -	pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight.
> +	pid, comm, dso, symbol, parent, cpu, socket, srcline, weight, local_weight.
>  
>  	Each key has following meaning:
>  
> @@ -79,6 +79,7 @@ OPTIONS
>  	- parent: name of function matched to the parent regex filter. Unmatched
>  	entries are displayed as "[other]".
>  	- cpu: cpu number the task ran at the time of sample
> +	- socket: processor socket number the task ran at the time of sample
>  	- srcline: filename and line number executed at the time of sample.  The
>  	DWARF debugging info must be provided.
>  	- srcfile: file name of the source file of the same. Requires dwarf
> diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> index de6d58e..5d04d28 100644
> --- a/tools/perf/util/hist.h
> +++ b/tools/perf/util/hist.h
> @@ -29,6 +29,7 @@ enum hist_column {
>  	HISTC_COMM,
>  	HISTC_PARENT,
>  	HISTC_CPU,
> +	HISTC_SOCKET,
>  	HISTC_SRCLINE,
>  	HISTC_SRCFILE,
>  	HISTC_MISPREDICT,
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index a97bcee..c4a32b9 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -421,6 +421,27 @@ struct sort_entry sort_cpu = {
>  	.se_width_idx	= HISTC_CPU,
>  };
>  
> +/* --sort socket */
> +
> +static int64_t
> +sort__socket_cmp(struct hist_entry *left, struct hist_entry *right)
> +{
> +	return right->socket - left->socket;
> +}
> +
> +static int hist_entry__socket_snprintf(struct hist_entry *he, char *bf,
> +				    size_t size, unsigned int width)
> +{
> +	return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket);
> +}
> +
> +struct sort_entry sort_socket = {
> +	.se_header      = "SOCKET",
> +	.se_cmp	        = sort__socket_cmp,
> +	.se_snprintf    = hist_entry__socket_snprintf,
> +	.se_width_idx	= HISTC_SOCKET,
> +};
> +
>  /* sort keys for branch stacks */
>  
>  static int64_t
> @@ -1248,6 +1269,7 @@ static struct sort_dimension common_sort_dimensions[] = {
>  	DIM(SORT_SYM, "symbol", sort_sym),
>  	DIM(SORT_PARENT, "parent", sort_parent),
>  	DIM(SORT_CPU, "cpu", sort_cpu),
> +	DIM(SORT_SOCKET, "socket", sort_socket),
>  	DIM(SORT_SRCLINE, "srcline", sort_srcline),
>  	DIM(SORT_SRCFILE, "srcfile", sort_srcfile),
>  	DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
> diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
> index 7cf1cf7..654ac8a 100644
> --- a/tools/perf/util/sort.h
> +++ b/tools/perf/util/sort.h
> @@ -173,6 +173,7 @@ enum sort_type {
>  	SORT_SYM,
>  	SORT_PARENT,
>  	SORT_CPU,
> +	SORT_SOCKET,
>  	SORT_SRCLINE,
>  	SORT_SRCFILE,
>  	SORT_LOCAL_WEIGHT,
> -- 
> 1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219366 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 01:00 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q587E-7sW-1@gated-at.bofh.it>
In reply to#1219364
Em Fri, Sep 04, 2015 at 07:41:39PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 04, 2015 at 10:45:43AM -0400, kan.liang@intel.com escreveu:
> > From: Kan Liang <kan.liang@intel.com>
> > 
> > This patch enable perf report to sort by processor socket
> > 
> > $ perf report --stdio --sort socket,comm,dso,symbol
> >  # 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
> >  #
> >  # Overhead  SOCKET  Command    Shared Object     Symbol
> >  # ........  ......  .........  ................
> >  .................................
> 
> So this works in 'perf top' only for the first screen rendering, when it
> refreshes we lose the "SOCKET" header (why all caps?) and the colum
> stops being %03d and instead becomes %d, I am checking now.

Patch below fix this, but we stumble in another problem, when zooming it
is not eliding the SOCKET column, i.e. if we're zooming into a column,
it will have the same value for all entries, no use in showing it, save
some columns, will check that as well.

Will fold the fixes to the patches where the problems were introduced,
the feature is cool, one more zoom! :-)

Thanks,

- Arnaldo

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index bb633cd4730a..67b48616ab31 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -146,6 +146,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 		hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
 	}
 
+	hists__new_col_len(hists, HISTC_SOCKET, 6);
 	hists__new_col_len(hists, HISTC_MEM_LOCKED, 6);
 	hists__new_col_len(hists, HISTC_MEM_TLB, 22);
 	hists__new_col_len(hists, HISTC_MEM_SNOOP, 12);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219371 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 01:10 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q58hk-7TD-19@gated-at.bofh.it>
In reply to#1219366
Em Fri, Sep 04, 2015 at 07:52:55PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 04, 2015 at 07:41:39PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Sep 04, 2015 at 10:45:43AM -0400, kan.liang@intel.com escreveu:
> > > From: Kan Liang <kan.liang@intel.com>
> > > 
> > > This patch enable perf report to sort by processor socket
> > > 
> > > $ perf report --stdio --sort socket,comm,dso,symbol
> > >  # 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
> > >  #
> > >  # Overhead  SOCKET  Command    Shared Object     Symbol
> > >  # ........  ......  .........  ................
> > >  .................................
> > 
> > So this works in 'perf top' only for the first screen rendering, when it
> > refreshes we lose the "SOCKET" header (why all caps?) and the colum
> > stops being %03d and instead becomes %d, I am checking now.
> 
> Patch below fix this, but we stumble in another problem, when zooming it
> is not eliding the SOCKET column, i.e. if we're zooming into a column,
> it will have the same value for all entries, no use in showing it, save
> some columns, will check that as well.
> 
> Will fold the fixes to the patches where the problems were introduced,
> the feature is cool, one more zoom! :-)

One more fixed, see below, now we have another, using ESC should remove
the last applied Zoom operation, just like for the other Zoom operations
(DSO, thread, etc), looking at that now.

- Arnaldo

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index d695fd2b6228..67d40feb1880 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1680,12 +1680,14 @@ add_exit_opt(struct hist_browser *browser __maybe_unused,
 static int
 do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
 {
-	if (browser->hists->socket_filter > -1)
+	if (browser->hists->socket_filter > -1) {
 		browser->hists->socket_filter = -1;
-	else
+		perf_hpp__set_elide(HISTC_SOCKET, false);
+	} else {
 		browser->hists->socket_filter = act->socket;
+		perf_hpp__set_elide(HISTC_SOCKET, true);
+	}
 
-	perf_hpp__set_elide(HISTC_SOCKET, false);
 	hists__filter_by_socket(browser->hists);
 	hist_browser__reset(browser);
 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219377 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 01:30 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q58AG-8fA-5@gated-at.bofh.it>
In reply to#1219371
Em Fri, Sep 04, 2015 at 08:25:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> > One more fixed, see below, now we have another, using ESC should remove
> > the last applied Zoom operation, just like for the other Zoom operations
> > (DSO, thread, etc), looking at that now.
> 
> Fixed, see below, to test, press S, then d to zoom into Socket then DSO
> and then press ESC to unzoom one level (the DSO in this case) then ESC
> again, to unzoom the Socket one.
> 
> If you use the left arrow key it will be equivalent to ESC, but we'll
> repurpose the left/right arrows for horizontal scrolling soon.
> 
Ooops, here it is:


diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 67d40feb1880..e4fd40f72b4a 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1681,11 +1681,13 @@ 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);
@@ -1794,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;
 
@@ -1944,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':
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219382 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 01:40 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q58Kl-8qH-13@gated-at.bofh.it>
In reply to#1219377
Em Fri, Sep 04, 2015 at 08:26:18PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 04, 2015 at 08:25:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > One more fixed, see below, now we have another, using ESC should remove
> > > the last applied Zoom operation, just like for the other Zoom operations
> > > (DSO, thread, etc), looking at that now.
> > 
> > Fixed, see below, to test, press S, then d to zoom into Socket then DSO
> > and then press ESC to unzoom one level (the DSO in this case) then ESC
> > again, to unzoom the Socket one.
> > 
> > If you use the left arrow key it will be equivalent to ESC, but we'll
> > repurpose the left/right arrows for horizontal scrolling soon.
> > 
> Ooops, here it is:

Ok, I have all updated and pushed to my perf/core branch, please take a
look/test.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219379 — Re: [PATCH 2/5] perf,tools: Support new sort type --socket

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-05 01:30 +0200
SubjectRe: [PATCH 2/5] perf,tools: Support new sort type --socket
Message-ID<q58AG-8fA-7@gated-at.bofh.it>
In reply to#1219371
Em Fri, Sep 04, 2015 at 08:06:21PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 04, 2015 at 07:52:55PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Sep 04, 2015 at 07:41:39PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Fri, Sep 04, 2015 at 10:45:43AM -0400, kan.liang@intel.com escreveu:
> > > > From: Kan Liang <kan.liang@intel.com>
> > > > 
> > > > This patch enable perf report to sort by processor socket
> > > > 
> > > > $ perf report --stdio --sort socket,comm,dso,symbol
> > > >  # 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
> > > >  #
> > > >  # Overhead  SOCKET  Command    Shared Object     Symbol
> > > >  # ........  ......  .........  ................
> > > >  .................................
> > > 
> > > So this works in 'perf top' only for the first screen rendering, when it
> > > refreshes we lose the "SOCKET" header (why all caps?) and the colum
> > > stops being %03d and instead becomes %d, I am checking now.
> > 
> > Patch below fix this, but we stumble in another problem, when zooming it
> > is not eliding the SOCKET column, i.e. if we're zooming into a column,
> > it will have the same value for all entries, no use in showing it, save
> > some columns, will check that as well.
> > 
> > Will fold the fixes to the patches where the problems were introduced,
> > the feature is cool, one more zoom! :-)
> 
> One more fixed, see below, now we have another, using ESC should remove
> the last applied Zoom operation, just like for the other Zoom operations
> (DSO, thread, etc), looking at that now.

Fixed, see below, to test, press S, then d to zoom into Socket then DSO
and then press ESC to unzoom one level (the DSO in this case) then ESC
again, to unzoom the Socket one.

If you use the left arrow key it will be equivalent to ESC, but we'll
repurpose the left/right arrows for horizontal scrolling soon.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219346 — [PATCH 3/5] perf,report: introduce socket-filter option

Fromkan.liang@intel.com
Date2015-09-05 00:10 +0200
Subject[PATCH 3/5] perf,report: introduce socket-filter option
Message-ID<q57lg-6z4-13@gated-at.bofh.it>
In reply to#1219341
From: Kan Liang <kan.liang@intel.com>

Introduce --socket-filter option for perf report to only show processor
socket that match with this filter.

 perf report --socket-filter 1 --stdio
 # To display the perf.data header info, please use
 --header/--header-only options.
 #
 #
 # Total Lost Samples: 0
 #
 # Samples: 752  of event 'cycles'
 # Event count (approx.): 350995599
 # Processor Socket: 1
 #
 # Overhead  Command    Shared Object     Symbol
 # ........  .........  ................
 .................................
 #
    97.02%  test       test              [.] plusB_c
     0.97%  test       test              [.] plusA_c
     0.23%  swapper    [kernel.vmlinux]  [k] acpi_idle_do_entry
     0.09%  rcu_sched  [kernel.vmlinux]  [k]
dyntick_save_progress_counter
     0.01%  swapper    [kernel.vmlinux]  [k] task_waking_fair
     0.00%  swapper    [kernel.vmlinux]  [k] run_timer_softirq

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/Documentation/perf-report.txt |  3 +++
 tools/perf/builtin-report.c              | 11 +++++++++++
 tools/perf/ui/browsers/hists.c           |  4 ++++
 tools/perf/util/hist.c                   | 16 ++++++++++++++++
 tools/perf/util/hist.h                   |  4 +++-
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 92361a7..b941d5e 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -350,6 +350,9 @@ include::itrace.txt[]
 	This option extends the perf report to show reference callgraphs,
 	which collected by reference event, in no callgraph event.
 
+--socket-filter::
+	Only report the samples on the processor socket that match with this filter
+
 include::callchain-overhead-calculation.txt[]
 
 SEE ALSO
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index affd70d..4b43245 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -62,6 +62,7 @@ struct report {
 	float			min_percent;
 	u64			nr_entries;
 	u64			queue_size;
+	int			socket_filter;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
@@ -290,6 +291,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
 	struct perf_evsel *evsel = hists_to_evsel(hists);
 	char buf[512];
 	size_t size = sizeof(buf);
+	int socket = hists->socket_filter;
 
 	if (symbol_conf.filter_relative) {
 		nr_samples = hists->stats.nr_non_filtered_samples;
@@ -330,6 +332,10 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
 		ret += fprintf(fp, "\n# Sort order   : %s", sort_order ? : default_mem_sort_order);
 	} else
 		ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events);
+
+	if (socket > -1)
+		ret += fprintf(fp, "\n# Processor Socket: %d", socket);
+
 	return ret + fprintf(fp, "\n#\n");
 }
 
@@ -454,6 +460,8 @@ static void report__collapse_hists(struct report *rep)
 		if (pos->idx == 0)
 			hists->symbol_filter_str = rep->symbol_filter_str;
 
+		hists->socket_filter = rep->socket_filter;
+
 		hists__collapse_resort(hists, &prog);
 
 		/* Non-group events are considered as leader */
@@ -639,6 +647,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		},
 		.max_stack		 = PERF_MAX_STACK_DEPTH,
 		.pretty_printing_style	 = "normal",
+		.socket_filter		 = -1,
 	};
 	const struct option options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
@@ -751,6 +760,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 			"Show full source file name path for source lines"),
 	OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph,
 		    "Show callgraph from reference event"),
+	OPT_INTEGER(0, "socket-filter", &report.socket_filter,
+		    "only show processor socket that match with this filter"),
 	OPT_END()
 	};
 	struct perf_data_file file = {
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cf86f2d..457f24c 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1261,6 +1261,7 @@ static int hists__browser_title(struct hists *hists,
 	int printed;
 	const struct dso *dso = hists->dso_filter;
 	const struct thread *thread = hists->thread_filter;
+	int socket = hists->socket_filter;
 	unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
 	u64 nr_events = hists->stats.total_period;
 	struct perf_evsel *evsel = hists_to_evsel(hists);
@@ -1314,6 +1315,9 @@ static int hists__browser_title(struct hists *hists,
 	if (dso)
 		printed += scnprintf(bf + printed, size - printed,
 				    ", DSO: %s", dso->short_name);
+	if (socket > -1)
+		printed += scnprintf(bf + printed, size - printed,
+				    ", Processor Socket: %d", socket);
 	if (!is_report_browser(hbt)) {
 		struct perf_top *top = hbt->arg;
 
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 80c4683..d7e53c2 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -15,6 +15,8 @@ static bool hists__filter_entry_by_thread(struct hists *hists,
 					  struct hist_entry *he);
 static bool hists__filter_entry_by_symbol(struct hists *hists,
 					  struct hist_entry *he);
+static bool hists__filter_entry_by_socket(struct hists *hists,
+					  struct hist_entry *he);
 
 u16 hists__col_len(struct hists *hists, enum hist_column col)
 {
@@ -1025,6 +1027,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
 	hists__filter_entry_by_dso(hists, he);
 	hists__filter_entry_by_thread(hists, he);
 	hists__filter_entry_by_symbol(hists, he);
+	hists__filter_entry_by_socket(hists, he);
 }
 
 void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
@@ -1293,6 +1296,18 @@ void hists__filter_by_symbol(struct hists *hists)
 	}
 }
 
+static bool hists__filter_entry_by_socket(struct hists *hists,
+					  struct hist_entry *he)
+{
+	if ((hists->socket_filter > -1) &&
+	    (he->socket != hists->socket_filter)) {
+		he->filtered |= (1 << HIST_FILTER__SOCKET);
+		return true;
+	}
+
+	return false;
+}
+
 void events_stats__inc(struct events_stats *stats, u32 type)
 {
 	++stats->nr_events[0];
@@ -1518,6 +1533,7 @@ static int hists_evsel__init(struct perf_evsel *evsel)
 	hists->entries_collapsed = RB_ROOT;
 	hists->entries = RB_ROOT;
 	pthread_mutex_init(&hists->lock, NULL);
+	hists->socket_filter = -1;
 	return 0;
 }
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 5d04d28..ef682f2 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -20,6 +20,7 @@ enum hist_filter {
 	HIST_FILTER__SYMBOL,
 	HIST_FILTER__GUEST,
 	HIST_FILTER__HOST,
+	HIST_FILTER__SOCKET,
 };
 
 enum hist_column {
@@ -71,6 +72,7 @@ struct hists {
 	struct events_stats	stats;
 	u64			event_stream;
 	u16			col_len[HISTC_NR_COLS];
+	int			socket_filter;
 };
 
 struct hist_entry_iter;
@@ -149,7 +151,7 @@ void hists__filter_by_symbol(struct hists *hists);
 static inline bool hists__has_filter(struct hists *hists)
 {
 	return hists->thread_filter || hists->dso_filter ||
-		hists->symbol_filter_str;
+		hists->symbol_filter_str || (hists->socket_filter > -1);
 }
 
 u16 hists__col_len(struct hists *hists, enum hist_column col);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1219347 — [PATCH 5/5] perf,test: test hists socket filter

Fromkan.liang@intel.com
Date2015-09-05 00:10 +0200
Subject[PATCH 5/5] perf,test: test hists socket filter
Message-ID<q57lg-6z4-23@gated-at.bofh.it>
In reply to#1219341
From: Kan Liang <kan.liang@intel.com>

Add test case for hists socket filter.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/tests/hists_filter.c | 55 +++++++++++++++++++++++++++++++++--------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index ce48775..818acf8 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -16,30 +16,31 @@ struct sample {
 	struct thread *thread;
 	struct map *map;
 	struct symbol *sym;
+	int socket;
 };
 
 /* For the numbers, see hists_common.c */
 static struct sample fake_samples[] = {
 	/* perf [kernel] schedule() */
-	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_SCHEDULE, },
+	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_SCHEDULE, .socket = 0 },
 	/* perf [perf]   main() */
-	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_PERF_MAIN, },
+	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_PERF_MAIN, .socket = 0 },
 	/* perf [libc]   malloc() */
-	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_LIBC_MALLOC, },
+	{ .pid = FAKE_PID_PERF1, .ip = FAKE_IP_LIBC_MALLOC, .socket = 0 },
 	/* perf [perf]   main() */
-	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_MAIN, }, /* will be merged */
+	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_MAIN, .socket = 0 }, /* will be merged */
 	/* perf [perf]   cmd_record() */
-	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_CMD_RECORD, },
+	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_CMD_RECORD, .socket = 1 },
 	/* perf [kernel] page_fault() */
-	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_KERNEL_PAGE_FAULT, },
+	{ .pid = FAKE_PID_PERF2, .ip = FAKE_IP_KERNEL_PAGE_FAULT, .socket = 1 },
 	/* bash [bash]   main() */
-	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_BASH_MAIN, },
+	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_BASH_MAIN, .socket = 2 },
 	/* bash [bash]   xmalloc() */
-	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_BASH_XMALLOC, },
+	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_BASH_XMALLOC, .socket = 2 },
 	/* bash [libc]   malloc() */
-	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_LIBC_MALLOC, },
+	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_LIBC_MALLOC, .socket = 3 },
 	/* bash [kernel] page_fault() */
-	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_KERNEL_PAGE_FAULT, },
+	{ .pid = FAKE_PID_BASH,  .ip = FAKE_IP_KERNEL_PAGE_FAULT, .socket = 3 },
 };
 
 static int add_hist_entries(struct perf_evlist *evlist,
@@ -83,6 +84,7 @@ static int add_hist_entries(struct perf_evlist *evlist,
 							  &sample) < 0)
 				goto out;
 
+			al.socket = fake_samples[i].socket;
 			if (hist_entry_iter__add(&iter, &al,
 						 PERF_MAX_STACK_DEPTH, NULL) < 0) {
 				addr_location__put(&al);
@@ -253,6 +255,39 @@ int test__hists_filter(void)
 		TEST_ASSERT_VAL("Unmatched total period for symbol filter",
 				hists->stats.total_non_filtered_period == 300);
 
+		/* remove symbol filter first */
+		hists->symbol_filter_str = NULL;
+		hists__filter_by_symbol(hists);
+
+		/* now applying socket filters */
+		hists->socket_filter = 2;
+		hists__filter_by_socket(hists);
+
+		if (verbose > 2) {
+			pr_info("Histogram for socket filters\n");
+			print_hists_out(hists);
+		}
+
+		/* normal stats should be invariant */
+		TEST_ASSERT_VAL("Invalid nr samples",
+				hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+		TEST_ASSERT_VAL("Invalid nr hist entries",
+				hists->nr_entries == 9);
+		TEST_ASSERT_VAL("Invalid total period",
+				hists->stats.total_period == 1000);
+
+		/* but filter stats are changed */
+		TEST_ASSERT_VAL("Unmatched nr samples for socket filter",
+				hists->stats.nr_non_filtered_samples == 2);
+		TEST_ASSERT_VAL("Unmatched nr hist entries for socket filter",
+				hists->nr_non_filtered_entries == 2);
+		TEST_ASSERT_VAL("Unmatched total period for socket filter",
+				hists->stats.total_non_filtered_period == 200);
+
+		/* remove socket filter first */
+		hists->socket_filter = -1;
+		hists__filter_by_socket(hists);
+
 		/* now applying all filters at once. */
 		hists->thread_filter = fake_samples[1].thread;
 		hists->dso_filter = fake_samples[1].map->dso;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web