* [GIT PULL 0/4] perf test improvements
@ 2011-12-02 16:19 Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 1/4] perf evlist: Always do automatic allocation of pollfd and mmap structures Arnaldo Carvalho de Melo
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 16:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian, arnaldo.melo
Hi Ingo,
Please consider pulling from:
git://github.com/acmel/linux.git perf/core
Now there are 29 outstanding changesets on this branch.
Regards,
- Arnaldo
Arnaldo Carvalho de Melo (4):
perf evlist: Always do automatic allocation of pollfd and mmap structures
perf test: Allow running just a subset of the available tests
perf event: Introduce perf_event__fprintf
perf test: Validate PERF_RECORD_ events and perf_sample fields
tools/perf/Documentation/perf-test.txt | 8 +-
tools/perf/builtin-record.c | 6 -
tools/perf/builtin-stat.c | 3 +-
tools/perf/builtin-test.c | 418 ++++++++++++++++++++++++++++++--
tools/perf/builtin-top.c | 19 +--
tools/perf/util/event.c | 54 ++++-
tools/perf/util/event.h | 6 +
tools/perf/util/evlist.c | 4 +-
tools/perf/util/evlist.h | 2 -
9 files changed, 465 insertions(+), 55 deletions(-)
--
1.7.8.rc0.35.gee6df
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/4] perf evlist: Always do automatic allocation of pollfd and mmap structures
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
@ 2011-12-02 16:19 ` Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 2/4] perf test: Allow running just a subset of the available tests Arnaldo Carvalho de Melo
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 16:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
At first tools were required to do that, but while writing the python
bindings to simplify the API I made them auto-allocate when needed.
This just makes record, stat and top use that auto allocation,
simplifying them a bit.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-iokhcvkzzijr3keioubx8hlq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-record.c | 6 ------
tools/perf/builtin-stat.c | 3 +--
tools/perf/builtin-top.c | 19 ++++---------------
tools/perf/util/evlist.c | 4 ++--
tools/perf/util/evlist.h | 2 --
5 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7d4fdaa..766fa0a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -778,16 +778,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
usage_with_options(record_usage, record_options);
list_for_each_entry(pos, &evsel_list->entries, node) {
- if (perf_evsel__alloc_fd(pos, evsel_list->cpus->nr,
- evsel_list->threads->nr) < 0)
- goto out_free_fd;
if (perf_header__push_event(pos->attr.config, event_name(pos)))
goto out_free_fd;
}
- if (perf_evlist__alloc_pollfd(evsel_list) < 0)
- goto out_free_fd;
-
if (rec->opts.user_interval != ULLONG_MAX)
rec->opts.default_interval = rec->opts.user_interval;
if (rec->opts.user_freq != UINT_MAX)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 227befb..4356144 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1240,8 +1240,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
list_for_each_entry(pos, &evsel_list->entries, node) {
if (perf_evsel__alloc_stat_priv(pos) < 0 ||
- perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0 ||
- perf_evsel__alloc_fd(pos, evsel_list->cpus->nr, evsel_list->threads->nr) < 0)
+ perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0)
goto out_free_fd;
}
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 50ff362..c3836b9 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1034,9 +1034,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
symbol_conf.use_callchain = false;
return 0;
- }
-
- else
+ } else
return -1;
/* get the min percentage */
@@ -1225,22 +1223,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
}
list_for_each_entry(pos, &top.evlist->entries, node) {
- if (perf_evsel__alloc_fd(pos, top.evlist->cpus->nr,
- top.evlist->threads->nr) < 0)
- goto out_free_fd;
/*
* Fill in the ones not specifically initialized via -c:
*/
- if (pos->attr.sample_period)
- continue;
-
- pos->attr.sample_period = top.default_interval;
+ if (!pos->attr.sample_period)
+ pos->attr.sample_period = top.default_interval;
}
- if (perf_evlist__alloc_pollfd(top.evlist) < 0 ||
- perf_evlist__alloc_mmap(top.evlist) < 0)
- goto out_free_fd;
-
top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node);
symbol_conf.priv_size = sizeof(struct annotation);
@@ -1270,7 +1259,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
}
status = __cmd_top(&top);
-out_free_fd:
+
perf_evlist__delete(top.evlist);
return status;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b36f26f..8b19e7a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -275,7 +275,7 @@ void perf_evlist__enable(struct perf_evlist *evlist)
}
}
-int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
+static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
{
int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries;
evlist->pollfd = malloc(sizeof(struct pollfd) * nfds);
@@ -431,7 +431,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
evlist->mmap = NULL;
}
-int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
+static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
{
evlist->nr_mmaps = evlist->cpus->nr;
if (evlist->cpus->map[0] == -1)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index f94ed7e..8922aee 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -72,7 +72,6 @@ int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist,
void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
int cpu, int thread, u64 id);
-int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
@@ -89,7 +88,6 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
const char *argv[]);
int perf_evlist__start_workload(struct perf_evlist *evlist);
-int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
bool overwrite);
void perf_evlist__munmap(struct perf_evlist *evlist);
--
1.7.8.rc0.35.gee6df
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/4] perf test: Allow running just a subset of the available tests
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 1/4] perf evlist: Always do automatic allocation of pollfd and mmap structures Arnaldo Carvalho de Melo
@ 2011-12-02 16:19 ` Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 3/4] perf event: Introduce perf_event__fprintf Arnaldo Carvalho de Melo
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 16:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To obtain a list of available tests:
[root@emilia linux]# perf test list
1: vmlinux symtab matches kallsyms
2: detect open syscall event
3: detect open syscall event on all cpus
4: read samples using the mmap interface
5: parse events tests
[root@emilia linux]#
To list just a subset:
[root@emilia linux]# perf test list syscall
2: detect open syscall event
3: detect open syscall event on all cpus
[root@emilia linux]#
To run a subset:
[root@emilia linux]# perf test detect
2: detect open syscall event: Ok
3: detect open syscall event on all cpus: Ok
[root@emilia linux]#
Specific tests can be chosen by number:
[root@emilia linux]# perf test 1 3 parse
1: vmlinux symtab matches kallsyms: Ok
3: detect open syscall event on all cpus: Ok
5: parse events tests: Ok
[root@emilia linux]#
Now to write more tests!
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-nqec2145qfxdgimux28aw7v8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-test.txt | 8 +++-
tools/perf/builtin-test.c | 81 +++++++++++++++++++++++--------
2 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt
index 2c3b462..b24ac40 100644
--- a/tools/perf/Documentation/perf-test.txt
+++ b/tools/perf/Documentation/perf-test.txt
@@ -8,13 +8,19 @@ perf-test - Runs sanity tests.
SYNOPSIS
--------
[verse]
-'perf test <options>'
+'perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]'
DESCRIPTION
-----------
This command does assorted sanity tests, initially through linked routines but
also will look for a directory with more tests in the form of scripts.
+To get a list of available tests use 'perf test list', specifying a test name
+fragment will show all tests that have it.
+
+To run just specific tests, inform test name fragments or the numbers obtained
+from 'perf test list'.
+
OPTIONS
-------
-v::
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 77d68bf..3ab2722 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -15,8 +15,6 @@
#include "util/thread_map.h"
#include "../../include/linux/hw_breakpoint.h"
-static long page_size;
-
static int vmlinux_matches_kallsyms_filter(struct map *map __used, struct symbol *sym)
{
bool *visited = symbol__priv(sym);
@@ -32,6 +30,7 @@ static int test__vmlinux_matches_kallsyms(void)
struct map *kallsyms_map, *vmlinux_map;
struct machine kallsyms, vmlinux;
enum map_type type = MAP__FUNCTION;
+ long page_size = sysconf(_SC_PAGE_SIZE);
struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", };
/*
@@ -871,41 +870,81 @@ static struct test {
},
};
-static int __cmd_test(void)
+static bool perf_test__matches(int curr, int argc, const char *argv[])
{
- int i = 0;
+ int i;
+
+ if (argc == 0)
+ return true;
+
+ for (i = 0; i < argc; ++i) {
+ char *end;
+ long nr = strtoul(argv[i], &end, 10);
+
+ if (*end == '\0') {
+ if (nr == curr + 1)
+ return true;
+ continue;
+ }
- page_size = sysconf(_SC_PAGE_SIZE);
+ if (strstr(tests[curr].desc, argv[i]))
+ return true;
+ }
+
+ return false;
+}
+
+static int __cmd_test(int argc, const char *argv[])
+{
+ int i = 0;
while (tests[i].func) {
- int err;
- pr_info("%2d: %s:", i + 1, tests[i].desc);
+ int curr = i++, err;
+
+ if (!perf_test__matches(curr, argc, argv))
+ continue;
+
+ pr_info("%2d: %s:", i, tests[curr].desc);
pr_debug("\n--- start ---\n");
- err = tests[i].func();
- pr_debug("---- end ----\n%s:", tests[i].desc);
+ err = tests[curr].func();
+ pr_debug("---- end ----\n%s:", tests[curr].desc);
pr_info(" %s\n", err ? "FAILED!\n" : "Ok");
- ++i;
}
return 0;
}
-static const char * const test_usage[] = {
- "perf test [<options>]",
- NULL,
-};
+static int perf_test__list(int argc, const char **argv)
+{
+ int i = 0;
+
+ while (tests[i].func) {
+ int curr = i++;
+
+ if (argc > 1 && !strstr(tests[curr].desc, argv[1]))
+ continue;
+
+ pr_info("%2d: %s\n", i, tests[curr].desc);
+ }
+
+ return 0;
+}
-static const struct option test_options[] = {
+int cmd_test(int argc, const char **argv, const char *prefix __used)
+{
+ const char * const test_usage[] = {
+ "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
+ NULL,
+ };
+ const struct option test_options[] = {
OPT_INTEGER('v', "verbose", &verbose,
"be more verbose (show symbol address, etc)"),
OPT_END()
-};
+ };
-int cmd_test(int argc, const char **argv, const char *prefix __used)
-{
argc = parse_options(argc, argv, test_options, test_usage, 0);
- if (argc)
- usage_with_options(test_usage, test_options);
+ if (argc >= 1 && !strcmp(argv[0], "list"))
+ return perf_test__list(argc, argv);
symbol_conf.priv_size = sizeof(int);
symbol_conf.sort_by_name = true;
@@ -916,5 +955,5 @@ int cmd_test(int argc, const char **argv, const char *prefix __used)
setup_pager();
- return __cmd_test();
+ return __cmd_test(argc, argv);
}
--
1.7.8.rc0.35.gee6df
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/4] perf event: Introduce perf_event__fprintf
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 1/4] perf evlist: Always do automatic allocation of pollfd and mmap structures Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 2/4] perf test: Allow running just a subset of the available tests Arnaldo Carvalho de Melo
@ 2011-12-02 16:19 ` Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields Arnaldo Carvalho de Melo
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 16:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
So that tools like 'perf test' can print the events when in verbose
mode, for instance.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-xnovdqfi25nc48gy6604k7yp@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/event.c | 54 +++++++++++++++++++++++++++++++++++++++++-----
tools/perf/util/event.h | 6 +++++
2 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 0ebbe76..97c479b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -433,6 +433,11 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
return err;
}
+size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp)
+{
+ return fprintf(fp, ": %s:%d\n", event->comm.comm, event->comm.tid);
+}
+
int perf_event__process_comm(struct perf_tool *tool __used,
union perf_event *event,
struct perf_sample *sample __used,
@@ -440,7 +445,8 @@ int perf_event__process_comm(struct perf_tool *tool __used,
{
struct thread *thread = machine__findnew_thread(machine, event->comm.tid);
- dump_printf(": %s:%d\n", event->comm.comm, event->comm.tid);
+ if (dump_trace)
+ perf_event__fprintf_comm(event, stdout);
if (thread == NULL || thread__set_comm(thread, event->comm.comm)) {
dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
@@ -566,6 +572,13 @@ out_problem:
return -1;
}
+size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
+{
+ return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n",
+ event->mmap.pid, event->mmap.tid, event->mmap.start,
+ event->mmap.len, event->mmap.pgoff, event->mmap.filename);
+}
+
int perf_event__process_mmap(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample __used,
@@ -576,9 +589,8 @@ int perf_event__process_mmap(struct perf_tool *tool,
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
int ret = 0;
- dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n",
- event->mmap.pid, event->mmap.tid, event->mmap.start,
- event->mmap.len, event->mmap.pgoff, event->mmap.filename);
+ if (dump_trace)
+ perf_event__fprintf_mmap(event, stdout);
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
cpumode == PERF_RECORD_MISC_KERNEL) {
@@ -606,6 +618,13 @@ out_problem:
return 0;
}
+size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
+{
+ return fprintf(fp, "(%d:%d):(%d:%d)\n",
+ event->fork.pid, event->fork.tid,
+ event->fork.ppid, event->fork.ptid);
+}
+
int perf_event__process_task(struct perf_tool *tool __used,
union perf_event *event,
struct perf_sample *sample __used,
@@ -614,8 +633,8 @@ int perf_event__process_task(struct perf_tool *tool __used,
struct thread *thread = machine__findnew_thread(machine, event->fork.tid);
struct thread *parent = machine__findnew_thread(machine, event->fork.ptid);
- dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
- event->fork.ppid, event->fork.ptid);
+ if (dump_trace)
+ perf_event__fprintf_task(event, stdout);
if (event->header.type == PERF_RECORD_EXIT) {
machine__remove_thread(machine, thread);
@@ -631,6 +650,29 @@ int perf_event__process_task(struct perf_tool *tool __used,
return 0;
}
+size_t perf_event__fprintf(union perf_event *event, FILE *fp)
+{
+ size_t ret = fprintf(fp, "PERF_RECORD_%s",
+ perf_event__name(event->header.type));
+
+ switch (event->header.type) {
+ case PERF_RECORD_COMM:
+ ret += perf_event__fprintf_comm(event, fp);
+ break;
+ case PERF_RECORD_FORK:
+ case PERF_RECORD_EXIT:
+ ret += perf_event__fprintf_task(event, fp);
+ break;
+ case PERF_RECORD_MMAP:
+ ret += perf_event__fprintf_mmap(event, fp);
+ break;
+ default:
+ ret += fprintf(fp, "\n");
+ }
+
+ return ret;
+}
+
int perf_event__process(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct machine *machine)
{
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index d8499e7..0d80201 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -2,6 +2,7 @@
#define __PERF_RECORD_H
#include <limits.h>
+#include <stdio.h>
#include "../perf.h"
#include "map.h"
@@ -199,4 +200,9 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
int sample_size, bool sample_id_all,
struct perf_sample *sample, bool swapped);
+size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
+size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
+size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
+size_t perf_event__fprintf(union perf_event *event, FILE *fp);
+
#endif /* __PERF_RECORD_H */
--
1.7.8.rc0.35.gee6df
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2011-12-02 16:19 ` [PATCH 3/4] perf event: Introduce perf_event__fprintf Arnaldo Carvalho de Melo
@ 2011-12-02 16:19 ` Arnaldo Carvalho de Melo
2011-12-02 17:07 ` David Ahern
2011-12-02 17:07 ` David Ahern
2011-12-02 16:54 ` [GIT PULL 0/4] perf test improvements David Ahern
2011-12-05 9:22 ` Ingo Molnar
5 siblings, 2 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 16:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
This new test will validate these new routines extracted from 'perf
record':
- perf_evlist__config_attrs
- perf_evlist__prepare_workload
- perf_evlist__start_workload
In addition to several other perf_evlist methods.
It consists of starting a simple workload, setting up just one event to
monitor ("cycles") requesting that several PERF_SAMPLE_ fields be
present in all events.
It then will check that the expected PERF_RECORD_ events are produced
and will sanity check all its fields.
Some checks performed:
. PERF_SAMPLE_TIME monotonically increases.
. PERF_SAMPLE_CPU is the one requested with sched_setaffinity
. PERF_SAMPLE_TID and PERF_SAMPLE_PID matches the one we forked
in perf_evlist__prepare_workload and that is stored in
evlist->workload.pid
. For the events where these fields are also present in its
pre-sample_id_all fields (e.g. event->mmap.pid), that they are what
is expected too.
. That we get a bunch of mmaps:
PATH/libcSUFFIX
PATH/ldSUFFIX
[vdso]
PATH/sleep
Example:
[root@emilia ~]# taskset -c 3,4 perf test -v1 perf_sample
6: Validate PERF_RECORD_* events & perf_sample fields:
--- start ---
7159480799825 3 PERF_RECORD_SAMPLE
7159480805584 3 PERF_RECORD_SAMPLE
7159480807814 3 PERF_RECORD_SAMPLE
7159480810430 3 PERF_RECORD_SAMPLE
7159480861511 3 PERF_RECORD_MMAP 8086/8086: [0x7fffffffd000(0x2000) @ 0x7fffffffd000]: //anon
7159481052516 3 PERF_RECORD_COMM: sleep:8086
7159481070188 3 PERF_RECORD_MMAP 8086/8086: [0x400000(0x6000) @ 0]: /bin/sleep
7159481077104 3 PERF_RECORD_MMAP 8086/8086: [0x3d06400000(0x221000) @ 0]: /lib64/ld-2.12.so
7159481092912 3 PERF_RECORD_MMAP 8086/8086: [0x7fff1adff000(0x1000) @ 0x7fff1adff000]: [vdso]
7159481196779 3 PERF_RECORD_MMAP 8086/8086: [0x3d06800000(0x37f000) @ 0]: /lib64/libc-2.12.so
7160481558435 3 PERF_RECORD_EXIT(8086:8086):(8086:8086)
---- end ----
Validate PERF_RECORD_* events & perf_sample fields: Ok
[root@emilia ~]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-svag18v2z4idas0dyz3umjpq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-test.c | 337 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 337 insertions(+), 0 deletions(-)
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 3ab2722..f1e3611 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -841,6 +841,339 @@ static int test__parse_events(void)
return ret;
}
+
+static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t **maskp,
+ size_t *sizep)
+{
+ cpu_set_t *mask;
+ size_t size;
+ int i, cpu = -1, nrcpus = 1024;
+realloc:
+ mask = CPU_ALLOC(nrcpus);
+ size = CPU_ALLOC_SIZE(nrcpus);
+ CPU_ZERO_S(size, mask);
+
+ if (sched_getaffinity(pid, size, mask) == -1) {
+ CPU_FREE(mask);
+ if (errno == EINVAL && nrcpus < (1024 << 8)) {
+ nrcpus = nrcpus << 2;
+ goto realloc;
+ }
+ perror("sched_getaffinity");
+ return -1;
+ }
+
+ for (i = 0; i < nrcpus; i++) {
+ if (CPU_ISSET_S(i, size, mask)) {
+ if (cpu == -1) {
+ cpu = i;
+ *maskp = mask;
+ *sizep = size;
+ } else
+ CPU_CLR_S(i, size, mask);
+ }
+ }
+
+ if (cpu == -1)
+ CPU_FREE(mask);
+
+ return cpu;
+}
+
+static int test__PERF_RECORD(void)
+{
+ struct perf_record_opts opts = {
+ .target_pid = -1,
+ .target_tid = -1,
+ .no_delay = true,
+ .freq = 10,
+ .mmap_pages = 256,
+ .sample_id_all_avail = true,
+ };
+ cpu_set_t *cpu_mask = NULL;
+ size_t cpu_mask_size = 0;
+ struct perf_evlist *evlist = perf_evlist__new(NULL, NULL);
+ struct perf_evsel *evsel;
+ struct perf_sample sample;
+ const char *cmd = "sleep";
+ const char *argv[] = { cmd, "1", NULL, };
+ char *bname;
+ u64 sample_type, prev_time = 0;
+ bool found_cmd_mmap = false,
+ found_libc_mmap = false,
+ found_vdso_mmap = false,
+ found_ld_mmap = false;
+ int err = -1, i, wakeups = 0, sample_size;
+ u32 cpu;
+ int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, };
+
+ if (evlist == NULL || argv == NULL) {
+ pr_debug("Not enough memory to create evlist\n");
+ goto out;
+ }
+
+ /*
+ * We need at least one evsel in the evlist, use the default
+ * one: "cycles".
+ */
+ err = perf_evlist__add_default(evlist);
+ if (err < 0) {
+ pr_debug("Not enough memory to create evsel\n");
+ goto out_delete_evlist;
+ }
+
+ /*
+ * Create maps of threads and cpus to monitor. In this case
+ * we start with all threads and cpus (-1, -1) but then in
+ * perf_evlist__prepare_workload we'll fill in the only thread
+ * we're monitoring, the one forked there.
+ */
+ err = perf_evlist__create_maps(evlist, opts.target_pid,
+ opts.target_tid, opts.cpu_list);
+ if (err < 0) {
+ pr_debug("Not enough memory to create thread/cpu maps\n");
+ goto out_delete_evlist;
+ }
+
+ /*
+ * Prepare the workload in argv[] to run, it'll fork it, and then wait
+ * for perf_evlist__start_workload() to exec it. This is done this way
+ * so that we have time to open the evlist (calling sys_perf_event_open
+ * on all the fds) and then mmap them.
+ */
+ err = perf_evlist__prepare_workload(evlist, &opts, argv);
+ if (err < 0) {
+ pr_debug("Couldn't run the workload!\n");
+ goto out_delete_evlist;
+ }
+
+ /*
+ * Config the evsels, setting attr->comm on the first one, etc.
+ */
+ evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
+ evsel->attr.sample_type |= PERF_SAMPLE_CPU;
+ evsel->attr.sample_type |= PERF_SAMPLE_TID;
+ evsel->attr.sample_type |= PERF_SAMPLE_TIME;
+ perf_evlist__config_attrs(evlist, &opts);
+
+ err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask,
+ &cpu_mask_size);
+ if (err < 0) {
+ pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno));
+ goto out_delete_evlist;
+ }
+
+ cpu = err;
+
+ /*
+ * So that we can check perf_sample.cpu on all the samples.
+ */
+ if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, cpu_mask) < 0) {
+ pr_debug("sched_setaffinity: %s\n", strerror(errno));
+ goto out_free_cpu_mask;
+ }
+
+ /*
+ * Call sys_perf_event_open on all the fds on all the evsels,
+ * grouping them if asked to.
+ */
+ err = perf_evlist__open(evlist, opts.group);
+ if (err < 0) {
+ pr_debug("perf_evlist__open: %s\n", strerror(errno));
+ goto out_delete_evlist;
+ }
+
+ /*
+ * mmap the first fd on a given CPU and ask for events for the other
+ * fds in the same CPU to be injected in the same mmap ring buffer
+ * (using ioctl(PERF_EVENT_IOC_SET_OUTPUT)).
+ */
+ err = perf_evlist__mmap(evlist, opts.mmap_pages, false);
+ if (err < 0) {
+ pr_debug("perf_evlist__mmap: %s\n", strerror(errno));
+ goto out_delete_evlist;
+ }
+
+ /*
+ * We'll need these two to parse the PERF_SAMPLE_* fields in each
+ * event.
+ */
+ sample_type = perf_evlist__sample_type(evlist);
+ sample_size = __perf_evsel__sample_size(sample_type);
+
+ /*
+ * Now that all is properly set up, enable the events, they will
+ * count just on workload.pid, which will start...
+ */
+ perf_evlist__enable(evlist);
+
+ /*
+ * Now!
+ */
+ perf_evlist__start_workload(evlist);
+
+ err = -1;
+
+ while (1) {
+ int before = total_events;
+
+ for (i = 0; i < evlist->nr_mmaps; i++) {
+ union perf_event *event;
+
+ while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
+ const u32 type = event->header.type;
+ const char *name = perf_event__name(type);
+
+ ++total_events;
+ if (type < PERF_RECORD_MAX)
+ nr_events[type]++;
+
+ if (perf_event__parse_sample(event, sample_type,
+ sample_size, true,
+ &sample, false) < 0) {
+ if (verbose)
+ perf_event__fprintf(event, stderr);
+ pr_debug("Couldn't parse sample\n");
+ goto out_err;
+ }
+
+ if (verbose) {
+ pr_info("%" PRIu64" %d ", sample.time, sample.cpu);
+ perf_event__fprintf(event, stderr);
+ }
+
+ if (prev_time > sample.time) {
+ pr_debug("%s going backwards in time, prev=%" PRIu64 ", curr=%" PRIu64 "\n",
+ name, prev_time, sample.time);
+ goto out_err;
+ }
+
+ prev_time = sample.time;
+
+ if (sample.cpu != cpu) {
+ pr_debug("%s with unexpected cpu, expected %d, got %d\n",
+ name, cpu, sample.cpu);
+ goto out_err;
+ }
+
+ if ((pid_t)sample.pid != evlist->workload.pid) {
+ pr_debug("%s with unexpected pid, expected %d, got %d\n",
+ name, evlist->workload.pid, sample.pid);
+ goto out_err;
+ }
+
+ if ((pid_t)sample.tid != evlist->workload.pid) {
+ pr_debug("%s with unexpected tid, expected %d, got %d\n",
+ name, evlist->workload.pid, sample.tid);
+ goto out_err;
+ }
+
+ if ((type == PERF_RECORD_COMM ||
+ type == PERF_RECORD_MMAP ||
+ type == PERF_RECORD_FORK ||
+ type == PERF_RECORD_EXIT) &&
+ (pid_t)event->comm.pid != evlist->workload.pid) {
+ pr_debug("%s with unexpected pid/tid\n", name);
+ goto out_err;
+ }
+
+ if ((type == PERF_RECORD_COMM ||
+ type == PERF_RECORD_MMAP) &&
+ event->comm.pid != event->comm.tid) {
+ pr_debug("%s with different pid/tid!\n", name);
+ goto out_err;
+ }
+
+ switch (type) {
+ case PERF_RECORD_COMM:
+ if (strcmp(event->comm.comm, cmd)) {
+ pr_debug("%s with unexpected comm!\n", name);
+ goto out_err;
+ }
+ break;
+ case PERF_RECORD_EXIT:
+ goto found_exit;
+ case PERF_RECORD_MMAP:
+ bname = strrchr(event->mmap.filename, '/');
+ if (bname != NULL) {
+ if (!found_cmd_mmap)
+ found_cmd_mmap = !strcmp(bname + 1, cmd);
+ if (!found_libc_mmap)
+ found_libc_mmap = !strncmp(bname + 1, "libc", 4);
+ if (!found_ld_mmap)
+ found_ld_mmap = !strncmp(bname + 1, "ld", 2);
+ } else if (!found_vdso_mmap)
+ found_vdso_mmap = !strcmp(event->mmap.filename, "[vdso]");
+ break;
+
+ case PERF_RECORD_SAMPLE:
+ /* Just ignore samples for now */
+ break;
+ default:
+ pr_debug("Unexpected perf_event->header.type %d!\n",
+ type);
+ goto out_err;
+ }
+ }
+ }
+
+ /*
+ * We don't use poll here because at least at 3.1 times the
+ * PERF_RECORD_{!SAMPLE} events don't honour
+ * perf_event_attr.wakeup_events, just PERF_EVENT_SAMPLE does.
+ */
+ if (total_events == before && false)
+ poll(evlist->pollfd, evlist->nr_fds, -1);
+
+ sleep(1);
+ if (++wakeups > 5) {
+ pr_debug("No PERF_RECORD_EXIT event!\n");
+ goto out_err;
+ }
+ }
+
+found_exit:
+ if (nr_events[PERF_RECORD_COMM] > 1) {
+ pr_debug("Excessive number of PERF_RECORD_COMM events!\n");
+ goto out_err;
+ }
+
+ if (nr_events[PERF_RECORD_COMM] == 0) {
+ pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd);
+ goto out_err;
+ }
+
+ if (!found_cmd_mmap) {
+ pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd);
+ goto out_err;
+ }
+
+ if (!found_libc_mmap) {
+ pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc");
+ goto out_err;
+ }
+
+ if (!found_ld_mmap) {
+ pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld");
+ goto out_err;
+ }
+
+ if (!found_vdso_mmap) {
+ pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]");
+ goto out_err;
+ }
+
+ err = 0;
+out_err:
+ perf_evlist__munmap(evlist);
+out_free_cpu_mask:
+ CPU_FREE(cpu_mask);
+out_delete_evlist:
+ perf_evlist__delete(evlist);
+out:
+ return err;
+}
+
static struct test {
const char *desc;
int (*func)(void);
@@ -866,6 +1199,10 @@ static struct test {
.func = test__parse_events,
},
{
+ .desc = "Validate PERF_RECORD_* events & perf_sample fields",
+ .func = test__PERF_RECORD,
+ },
+ {
.func = NULL,
},
};
--
1.7.8.rc0.35.gee6df
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [GIT PULL 0/4] perf test improvements
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
` (3 preceding siblings ...)
2011-12-02 16:19 ` [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields Arnaldo Carvalho de Melo
@ 2011-12-02 16:54 ` David Ahern
2011-12-02 18:22 ` Arnaldo Carvalho de Melo
2011-12-05 9:22 ` Ingo Molnar
5 siblings, 1 reply; 12+ messages in thread
From: David Ahern @ 2011-12-02 16:54 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, linux-kernel, Arnaldo Carvalho de Melo,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian, arnaldo.melo
On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> Hi Ingo,
>
> Please consider pulling from:
>
> git://github.com/acmel/linux.git perf/core
>
> Now there are 29 outstanding changesets on this branch.
What about the 2 commits on your urgent branch? I don't recall seeing a
response that those were picked up, and they are not in Linus' branch.
David
>
> Regards,
>
> - Arnaldo
>
> Arnaldo Carvalho de Melo (4):
> perf evlist: Always do automatic allocation of pollfd and mmap structures
> perf test: Allow running just a subset of the available tests
> perf event: Introduce perf_event__fprintf
> perf test: Validate PERF_RECORD_ events and perf_sample fields
>
> tools/perf/Documentation/perf-test.txt | 8 +-
> tools/perf/builtin-record.c | 6 -
> tools/perf/builtin-stat.c | 3 +-
> tools/perf/builtin-test.c | 418 ++++++++++++++++++++++++++++++--
> tools/perf/builtin-top.c | 19 +--
> tools/perf/util/event.c | 54 ++++-
> tools/perf/util/event.h | 6 +
> tools/perf/util/evlist.c | 4 +-
> tools/perf/util/evlist.h | 2 -
> 9 files changed, 465 insertions(+), 55 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields
2011-12-02 16:19 ` [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields Arnaldo Carvalho de Melo
@ 2011-12-02 17:07 ` David Ahern
2011-12-02 19:06 ` Arnaldo Carvalho de Melo
2011-12-02 17:07 ` David Ahern
1 sibling, 1 reply; 12+ messages in thread
From: David Ahern @ 2011-12-02 17:07 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, linux-kernel, Arnaldo Carvalho de Melo,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> +found_exit:
> + if (nr_events[PERF_RECORD_COMM] > 1) {
> + pr_debug("Excessive number of PERF_RECORD_COMM events!\n");
> + goto out_err;
> + }
> +
> + if (nr_events[PERF_RECORD_COMM] == 0) {
> + pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd);
> + goto out_err;
> + }
> +
> + if (!found_cmd_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd);
> + goto out_err;
> + }
> +
> + if (!found_libc_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc");
> + goto out_err;
> + }
> +
> + if (!found_ld_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld");
> + goto out_err;
> + }
> +
> + if (!found_vdso_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]");
> + goto out_err;
> + }
Since this is a test why not show all missed events rather than punt to
out_err on the first missed one?
David
> +
> + err = 0;
> +out_err:
> + perf_evlist__munmap(evlist);
> +out_free_cpu_mask:
> + CPU_FREE(cpu_mask);
> +out_delete_evlist:
> + perf_evlist__delete(evlist);
> +out:
> + return err;
> +}
> +
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields
2011-12-02 16:19 ` [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields Arnaldo Carvalho de Melo
2011-12-02 17:07 ` David Ahern
@ 2011-12-02 17:07 ` David Ahern
1 sibling, 0 replies; 12+ messages in thread
From: David Ahern @ 2011-12-02 17:07 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, linux-kernel, Arnaldo Carvalho de Melo,
Frederic Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Stephane Eranian
On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> +found_exit:
> + if (nr_events[PERF_RECORD_COMM] > 1) {
> + pr_debug("Excessive number of PERF_RECORD_COMM events!\n");
> + goto out_err;
> + }
> +
> + if (nr_events[PERF_RECORD_COMM] == 0) {
> + pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd);
> + goto out_err;
> + }
> +
> + if (!found_cmd_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd);
> + goto out_err;
> + }
> +
> + if (!found_libc_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc");
> + goto out_err;
> + }
> +
> + if (!found_ld_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld");
> + goto out_err;
> + }
> +
> + if (!found_vdso_mmap) {
> + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]");
> + goto out_err;
> + }
Since this is a test why not show all missed events rather than punt to
out_err on the first missed one?
David
> +
> + err = 0;
> +out_err:
> + perf_evlist__munmap(evlist);
> +out_free_cpu_mask:
> + CPU_FREE(cpu_mask);
> +out_delete_evlist:
> + perf_evlist__delete(evlist);
> +out:
> + return err;
> +}
> +
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GIT PULL 0/4] perf test improvements
2011-12-02 16:54 ` [GIT PULL 0/4] perf test improvements David Ahern
@ 2011-12-02 18:22 ` Arnaldo Carvalho de Melo
2011-12-05 15:46 ` Ingo Molnar
0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 18:22 UTC (permalink / raw)
To: David Ahern
Cc: Ingo Molnar, linux-kernel, Frederic Weisbecker, Mike Galbraith,
Paul Mackerras, Peter Zijlstra, Stephane Eranian, Linus Torvalds
Em Fri, Dec 02, 2011 at 09:54:24AM -0700, David Ahern escreveu:
>
>
> On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> > Hi Ingo,
> >
> > Please consider pulling from:
> >
> > git://github.com/acmel/linux.git perf/core
> >
> > Now there are 29 outstanding changesets on this branch.
>
> What about the 2 commits on your urgent branch? I don't recall seeing a
> response that those were picked up, and they are not in Linus' branch.
Waiting for Ingo on those. If they don't get picked by tomorrow I'll ask
Linus directly.
- Arnaldo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields
2011-12-02 17:07 ` David Ahern
@ 2011-12-02 19:06 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-12-02 19:06 UTC (permalink / raw)
To: David Ahern
Cc: Ingo Molnar, linux-kernel, Frederic Weisbecker, Mike Galbraith,
Paul Mackerras, Peter Zijlstra, Stephane Eranian
Em Fri, Dec 02, 2011 at 10:07:43AM -0700, David Ahern escreveu:
>
>
> On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> > +found_exit:
> > + if (!found_vdso_mmap) {
> > + pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]");
> > + goto out_err;
> > + }
>
>
> Since this is a test why not show all missed events rather than punt to
> out_err on the first missed one?
Right! And it was so, pushed this one there.
- Arnaldo
>From f71c49e5e985897850406a152ab99001cfb86f2a Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Fri, 2 Dec 2011 13:53:04 -0200
Subject: [PATCH 1/1] perf test: Soft errors shouldn't stop the "Validate
PERF_RECORD_" test
For errors that don't preclude checking for further errors, aka "soft"
errors, just continue testing for other errors.
Better coverage in verbose mode.
Suggested-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jafcokbj26m845dsgm2hx6az@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-test.c | 45 +++++++++++++++++++++------------------------
1 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index f1e3611..6173f78 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -903,7 +903,7 @@ static int test__PERF_RECORD(void)
found_libc_mmap = false,
found_vdso_mmap = false,
found_ld_mmap = false;
- int err = -1, i, wakeups = 0, sample_size;
+ int err = -1, errs = 0, i, wakeups = 0, sample_size;
u32 cpu;
int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, };
@@ -1012,8 +1012,6 @@ static int test__PERF_RECORD(void)
*/
perf_evlist__start_workload(evlist);
- err = -1;
-
while (1) {
int before = total_events;
@@ -1028,9 +1026,10 @@ static int test__PERF_RECORD(void)
if (type < PERF_RECORD_MAX)
nr_events[type]++;
- if (perf_event__parse_sample(event, sample_type,
- sample_size, true,
- &sample, false) < 0) {
+ err = perf_event__parse_sample(event, sample_type,
+ sample_size, true,
+ &sample, false);
+ if (err < 0) {
if (verbose)
perf_event__fprintf(event, stderr);
pr_debug("Couldn't parse sample\n");
@@ -1045,7 +1044,7 @@ static int test__PERF_RECORD(void)
if (prev_time > sample.time) {
pr_debug("%s going backwards in time, prev=%" PRIu64 ", curr=%" PRIu64 "\n",
name, prev_time, sample.time);
- goto out_err;
+ ++errs;
}
prev_time = sample.time;
@@ -1053,19 +1052,19 @@ static int test__PERF_RECORD(void)
if (sample.cpu != cpu) {
pr_debug("%s with unexpected cpu, expected %d, got %d\n",
name, cpu, sample.cpu);
- goto out_err;
+ ++errs;
}
if ((pid_t)sample.pid != evlist->workload.pid) {
pr_debug("%s with unexpected pid, expected %d, got %d\n",
name, evlist->workload.pid, sample.pid);
- goto out_err;
+ ++errs;
}
if ((pid_t)sample.tid != evlist->workload.pid) {
pr_debug("%s with unexpected tid, expected %d, got %d\n",
name, evlist->workload.pid, sample.tid);
- goto out_err;
+ ++errs;
}
if ((type == PERF_RECORD_COMM ||
@@ -1074,21 +1073,21 @@ static int test__PERF_RECORD(void)
type == PERF_RECORD_EXIT) &&
(pid_t)event->comm.pid != evlist->workload.pid) {
pr_debug("%s with unexpected pid/tid\n", name);
- goto out_err;
+ ++errs;
}
if ((type == PERF_RECORD_COMM ||
type == PERF_RECORD_MMAP) &&
event->comm.pid != event->comm.tid) {
pr_debug("%s with different pid/tid!\n", name);
- goto out_err;
+ ++errs;
}
switch (type) {
case PERF_RECORD_COMM:
if (strcmp(event->comm.comm, cmd)) {
pr_debug("%s with unexpected comm!\n", name);
- goto out_err;
+ ++errs;
}
break;
case PERF_RECORD_EXIT:
@@ -1112,7 +1111,7 @@ static int test__PERF_RECORD(void)
default:
pr_debug("Unexpected perf_event->header.type %d!\n",
type);
- goto out_err;
+ ++errs;
}
}
}
@@ -1128,42 +1127,40 @@ static int test__PERF_RECORD(void)
sleep(1);
if (++wakeups > 5) {
pr_debug("No PERF_RECORD_EXIT event!\n");
- goto out_err;
+ break;
}
}
found_exit:
if (nr_events[PERF_RECORD_COMM] > 1) {
pr_debug("Excessive number of PERF_RECORD_COMM events!\n");
- goto out_err;
+ ++errs;
}
if (nr_events[PERF_RECORD_COMM] == 0) {
pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd);
- goto out_err;
+ ++errs;
}
if (!found_cmd_mmap) {
pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd);
- goto out_err;
+ ++errs;
}
if (!found_libc_mmap) {
pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc");
- goto out_err;
+ ++errs;
}
if (!found_ld_mmap) {
pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld");
- goto out_err;
+ ++errs;
}
if (!found_vdso_mmap) {
pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]");
- goto out_err;
+ ++errs;
}
-
- err = 0;
out_err:
perf_evlist__munmap(evlist);
out_free_cpu_mask:
@@ -1171,7 +1168,7 @@ out_free_cpu_mask:
out_delete_evlist:
perf_evlist__delete(evlist);
out:
- return err;
+ return (err < 0 || errs > 0) ? -1 : 0;
}
static struct test {
--
1.7.8.rc0.35.gee6df
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [GIT PULL 0/4] perf test improvements
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
` (4 preceding siblings ...)
2011-12-02 16:54 ` [GIT PULL 0/4] perf test improvements David Ahern
@ 2011-12-05 9:22 ` Ingo Molnar
5 siblings, 0 replies; 12+ messages in thread
From: Ingo Molnar @ 2011-12-05 9:22 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, David Ahern, Frederic Weisbecker, Mike Galbraith,
Paul Mackerras, Peter Zijlstra, Stephane Eranian, arnaldo.melo
* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:
> Hi Ingo,
>
> Please consider pulling from:
>
> git://github.com/acmel/linux.git perf/core
>
> Now there are 29 outstanding changesets on this branch.
Pulled, thanks a lot Arnaldo!
Ingo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GIT PULL 0/4] perf test improvements
2011-12-02 18:22 ` Arnaldo Carvalho de Melo
@ 2011-12-05 15:46 ` Ingo Molnar
0 siblings, 0 replies; 12+ messages in thread
From: Ingo Molnar @ 2011-12-05 15:46 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: David Ahern, linux-kernel, Frederic Weisbecker, Mike Galbraith,
Paul Mackerras, Peter Zijlstra, Stephane Eranian, Linus Torvalds
* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:
> Em Fri, Dec 02, 2011 at 09:54:24AM -0700, David Ahern escreveu:
> >
> >
> > On 12/02/2011 09:19 AM, Arnaldo Carvalho de Melo wrote:
> > > Hi Ingo,
> > >
> > > Please consider pulling from:
> > >
> > > git://github.com/acmel/linux.git perf/core
> > >
> > > Now there are 29 outstanding changesets on this branch.
> >
> > What about the 2 commits on your urgent branch? I don't recall seeing a
> > response that those were picked up, and they are not in Linus' branch.
>
> Waiting for Ingo on those. If they don't get picked by
> tomorrow I'll ask Linus directly.
It should now all be in -tip, will send it to Linus today or
tomorrow.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-12-05 15:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02 16:19 [GIT PULL 0/4] perf test improvements Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 1/4] perf evlist: Always do automatic allocation of pollfd and mmap structures Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 2/4] perf test: Allow running just a subset of the available tests Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 3/4] perf event: Introduce perf_event__fprintf Arnaldo Carvalho de Melo
2011-12-02 16:19 ` [PATCH 4/4] perf test: Validate PERF_RECORD_ events and perf_sample fields Arnaldo Carvalho de Melo
2011-12-02 17:07 ` David Ahern
2011-12-02 19:06 ` Arnaldo Carvalho de Melo
2011-12-02 17:07 ` David Ahern
2011-12-02 16:54 ` [GIT PULL 0/4] perf test improvements David Ahern
2011-12-02 18:22 ` Arnaldo Carvalho de Melo
2011-12-05 15:46 ` Ingo Molnar
2011-12-05 9:22 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox