From 3a531260a14631ae8d231279b8738884bf808e7b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 20 Oct 2012 12:39:03 -0300 Subject: perf trace: Validate syscall id before growing syscall table In some cases the ID for a syscall read thru the raw_syscalls tracepoint is bogus, still needs to be investigated why, but to make the tool more robust first try to resolve the ID to a name via libaudit and if it fails, don't grow the table. Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-0lsokw3xor7c4ijo45u6bauh@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index dec8ced61fb..83c6515e425 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -56,6 +56,10 @@ static int trace__read_syscall_info(struct trace *trace, int id) { char tp_name[128]; struct syscall *sc; + const char *name = audit_syscall_to_name(id, trace->audit_machine); + + if (name == NULL) + return -1; if (id > trace->syscalls.max) { struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); @@ -75,11 +79,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) } sc = trace->syscalls.table + id; - sc->name = audit_syscall_to_name(id, trace->audit_machine); - if (sc->name == NULL) - return -1; - - sc->fmt = syscall_fmt__find(sc->name); + sc->name = name; + sc->fmt = syscall_fmt__find(sc->name); snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name); sc->tp_format = event_format__new("syscalls", tp_name); -- cgit v1.2.3 From fc551f8d4427150da1ee7cbb0f53525c49ef4bca Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 20 Oct 2012 13:08:46 -0300 Subject: perf trace: Check if sample raw_data field is set Sometimes we're segfaulting because we were expecting that the perf_sample.raw_data field was set as requested, but in some cases that needs further investigation, that field can be NULL, leading to segfaults. Make the tool more robust by checking that before calling any per event handlers that may try to use that field. Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-g1fmodl6ys4lq8honbj1igoi@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools') diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 83c6515e425..7aaee39f677 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -268,6 +268,13 @@ again: if (evlist->threads->map[0] == -1 || evlist->threads->nr > 1) printf("%d ", sample.tid); + if (sample.raw_data == NULL) { + printf("%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n", + perf_evsel__name(evsel), sample.tid, + sample.cpu, sample.raw_size); + continue; + } + handler = evsel->handler.func; handler(trace, evsel, &sample); } -- cgit v1.2.3 From 670ab5d21c7e168c89a36fdd2c69fb7af63d35a1 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Mon, 22 Oct 2012 16:12:23 +0900 Subject: perf help: Fix --help for builtins It seems that commit cc5848213329 ("perf help: Remove use of die and handle errors") caused the problem - it changed the initial value of 'help_format' from HELP_FORMAT_MAN to HELP_FORMAT_NONE. This broke the --help option for all builtins, that would produce no output, while 'man perf-top' would work it MANPATH is properly setup. Reported-by: Stephane Eranian Signed-off-by: Namhyung Kim Tested-by: David Ahern Acked-by: David Ahern Cc: David Ahern Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/87r4orj7zc.fsf@sejong.aot.lge.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 411ee5664e9..178b88ae3d2 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -414,7 +414,7 @@ static int show_html_page(const char *perf_cmd) int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) { bool show_all = false; - enum help_format help_format = HELP_FORMAT_NONE; + enum help_format help_format = HELP_FORMAT_MAN; struct option builtin_help_options[] = { OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), -- cgit v1.2.3 From 9fdbf671ba7e8adb2cbb93d716232ebcab55f6bd Mon Sep 17 00:00:00 2001 From: Luigi Semenzato Date: Tue, 21 Aug 2012 14:52:20 -0700 Subject: perf tools: do not flush maps on COMM for perf report This fixes a long-standing bug caused by the lack of separate COMM and EXEC record types, which makes "perf report" lose track of symbols when a process renames itself. With this fix (suggested by Stephane Eranian), a COMM (rename) no longer flushes the maps, which is the correct behavior. An EXEC also no longer flushes the maps, but this doesn't matter because as new mappings are created (for the executable and the libraries) the old mappings are automatically removed. This is not by accident: the functionality is necessary because DLLs can be explicitly loaded at any time with dlopen(), possibly on top of existing text, so "perf report" handles correctly the clobbering of new mappings on top of old ones. An alternative patch (which I proposed earlier) would be to introduce a separate PERF_RECORD_EXEC type, but it is a much larger change (about 300 lines) and is not necessary. Signed-off-by: Luigi Semenzato Tested-by: Stephane Eranian Acked-by: Stephane Eranian Cc: "Eric W. Biederman" Cc: "Rafael J. Wysocki" Cc: Alexander Viro Cc: Andi Kleen Cc: Andrew Morton Cc: David Ahern Cc: Frederic Weisbecker Cc: Greg Kroah-Hartman Cc: Ingo Molnar Cc: Lucas De Marchi Cc: Namhyung Kim Cc: Oleg Nesterov Cc: Olof Johansson Cc: Paul Gortmaker Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Robert Richter Cc: Sonny Rao Cc: Stephane Eranian Cc: Stephen Wilson Cc: Tejun Heo Cc: Vasiliy Kulikov Link: http://lkml.kernel.org/r/1345585940-6497-1-git-send-email-semenzato@chromium.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/thread.c | 1 - 1 file changed, 1 deletion(-) (limited to 'tools') diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index fb4b7ea6752..8b3e5939afb 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -39,7 +39,6 @@ int thread__set_comm(struct thread *self, const char *comm) err = self->comm == NULL ? -ENOMEM : 0; if (!err) { self->comm_set = true; - map_groups__flush(&self->mg); } return err; } -- cgit v1.2.3 From 42be73989c18931a394515b83aeae9246aa8b7b9 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sat, 20 Oct 2012 18:29:34 +0200 Subject: perf test: Fix exclude_guest parse events tests Event parsing tests are broken by following commit: perf tool: Precise mode requires exclude_guest commit 1342798cc13e3b48d9b5738f0c8fa812ccea8101 Author: David Ahern Date: Thu Sep 13 14:59:13 2012 -0600 which enables 'exclude_guest' modifier any time the 'precise' modifier is detected. Fixing related tests and adding special comment. Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa Tested-by: David Ahern Acked-by: David Ahern Cc: David Ahern Cc: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events-test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index 28c18d1d52c..516ecd9ddd6 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c @@ -513,7 +513,8 @@ static int test__group1(struct perf_evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); + /* use of precise requires exclude_guest */ + TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); @@ -599,7 +600,8 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused) TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); + /* use of precise requires exclude_guest */ + TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); @@ -662,7 +664,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); + /* use of precise requires exclude_guest */ + TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); @@ -676,7 +679,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused) TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); + /* use of precise requires exclude_guest */ + TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); -- cgit v1.2.3