[PATCH 2/3] perf evsel: Support perf_evsel__open(cpus > 1 && threads > 1)

Previous thread: [PATCH 1/3] perf test: Clarify some error reports in the open syscall test by Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 10:18 am. (1 message)

Next thread: Please check out TexasTrue.com! by Catherine Jackson on Tuesday, January 4, 2011 - 10:49 am. (1 message)
From: Arnaldo Carvalho de Melo
Date: Tuesday, January 4, 2011 - 10:18 am

Hi Ingo,

        Please consider pulling from:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core

Regards,

- Arnaldo

Arnaldo Carvalho de Melo (2):
  perf test: Clarify some error reports in the open syscall test
  perf evsel: Support perf_evsel__open(cpus > 1 && threads > 1)

Stephane Eranian (1):
  perf tools: Fix perf_event.h header usage

 tools/perf/builtin-test.c      |  124 +++++++++++++++++++++++++++++++++++++--
 tools/perf/util/evsel.c        |   75 +++++++++++++-----------
 tools/perf/util/evsel.h        |    2 +-
 tools/perf/util/parse-events.h |    2 +-
 4 files changed, 159 insertions(+), 44 deletions(-)

--

From: Arnaldo Carvalho de Melo
Date: Tuesday, January 4, 2011 - 10:18 am

From: Arnaldo Carvalho de Melo <acme@redhat.com>

And a test for it:

[acme@felicio linux]$ perf test
 1: vmlinux symtab matches kallsyms: Ok
 2: detect open syscall event: Ok
 3: detect open syscall event on all cpus: Ok
[acme@felicio linux]$

Translating C the test does:

1. generates different number of open syscalls on each CPU
   by using sched_setaffinity
2. Verifies that the expected number of events is generated
   on each CPU

It works as expected.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-test.c |  106 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/evsel.c   |   75 +++++++++++++++++---------------
 2 files changed, 146 insertions(+), 35 deletions(-)

diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 1c98434..c4be20c 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -234,6 +234,7 @@ out:
 	return err;
 }
 
+#include "util/cpumap.h"
 #include "util/evsel.h"
 #include <sys/types.h>
 
@@ -317,6 +318,107 @@ out_thread_map_delete:
 	return err;
 }
 
+#include <sched.h>
+
+static int test__open_syscall_event_on_all_cpus(void)
+{
+	int err = -1, fd, cpu;
+	struct thread_map *threads;
+	struct cpu_map *cpus;
+	struct perf_evsel *evsel;
+	unsigned int nr_open_calls = 111, i;
+	cpu_set_t *cpu_set;
+	size_t cpu_set_size;
+	int id = trace_event__id("sys_enter_open");
+
+	if (id < 0) {
+		pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
+		return -1;
+	}
+
+	threads = thread_map__new(-1, getpid());
+	if (threads == NULL) {
+		pr_debug("thread_map__new\n");
+		return -1;
+	}
+
+	cpus = cpu_map__new(NULL);
+	if (threads == NULL) ...
Previous thread: [PATCH 1/3] perf test: Clarify some error reports in the open syscall test by Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 10:18 am. (1 message)

Next thread: Please check out TexasTrue.com! by Catherine Jackson on Tuesday, January 4, 2011 - 10:49 am. (1 message)