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


Groups > linux.kernel > #1224320

[PATCH 27/27] perf test: Add entry for hists socket filter

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 27/27] perf test: Add entry for hists socket filter
Date 2015-09-14 18:50 +0200
Message-ID <q8F74-3qM-43@gated-at.bofh.it> (permalink)
References <q8EXn-3f1-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Add test case for hists socket filter.

Signed-off-by: Kan Liang <kan.liang@intel.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-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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 ce48775e6ada..818acf875dd0 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;
-- 
2.1.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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/27] perf/core2 improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:40 +0200
  [PATCH 01/27] perf tests: Take into account address of each objdump line Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:40 +0200
  [PATCH 03/27] perf tests: Stop reading if objdump output crossed sections Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:40 +0200
  [PATCH 12/27] perf env: Rename some leftovers from rename to perf_env Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 16/27] perf tools: Add tools/include into tags directories Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 14/27] perf hists browser: Fixup the "cpu" column width calculation Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 21/27] perf env: Introduce read_cpu_topology_map() method Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 19/27] tools lib api cpu: Introduce cpu.[ch] to obtain cpu related information Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 22/27] perf machine: Add pointer to sample's environment Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 11/27] perf env: Move perf_env out of header.h and session.c into separate object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 27/27] perf test: Add entry for hists socket filter Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 15/27] perf evsel: Remove forward declaration of 'struct perf_evlist' Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 10/27] perf tests: Introduce iterator function for tests Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 20/27] perf cpu_map: Use sysfs__read_int in get_{core,socket}_id() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 13/27] perf env: Adopt perf_header__set_cmdline Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 24/27] perf tools: Introduce new sort type "socket" for the processor socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 08/27] perf tools: Switch to tracing_path interface on appropriate places Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 23/27] perf tools: Add processor socket info to hist_entry and addr_location Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 25/27] perf report: Introduce --socket-filter option Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 26/27] perf hists browser: Zoom in/out for processor socket Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 18/27] tools lib api fs: Introduce sysfs__read_{int,ull}() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 17/27] perf env: Read msr pmu type from header Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 09/27] perf test: Add entry to test cpu topology Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 18:50 +0200
  [PATCH 07/27] tools lib api fs: Remove debugfs, tracefs and findfs objects Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 19:00 +0200
  [PATCH 06/27] tools lib api fs: Replace debugfs/tracefs objects interface with fs.c Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 19:00 +0200
  [PATCH 05/27] tools lib api fs: Make tracing_path_strerror_open message generic Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 19:00 +0200
  Re: [GIT PULL 00/27] perf/core2 improvements and fixes Ingo Molnar <mingo@kernel.org> - 2015-09-15 09:00 +0200

csiph-web