From acb61fc8ed73eb477a9044272d7a1b1f5a572f91 Mon Sep 17 00:00:00 2001 From: Alexander Yarygin Date: Wed, 9 Apr 2014 16:21:59 +0200 Subject: perf kvm: Fix 'Min time' counting in report command Every event in the perf-kvm has a 'stats' structure, which contains max/min/average/etc times of handling this event. The problem is that the 'perf-kvm stat report' command always shows that 'min time' is 0us for every event. Example: # perf kvm stat report Analyze events for all VCPUs: VM-EXIT Samples Samples% Time% Min Time Max Time Avg time [..] 0xB2 MSCH 12 0.07% 0.00% 0us 8us 7.31us ( +- 2.11% ) 0xB2 CHSC 12 0.07% 0.00% 0us 18us 9.39us ( +- 9.49% ) 0xB2 STPX 8 0.05% 0.00% 0us 2us 1.88us ( +- 7.18% ) 0xB2 STSI 7 0.04% 0.00% 0us 44us 16.49us ( +- 38.20% ) [..] This happens because the 'stats' structure is not initialized and stats->min equals to 0. Lets initialize the structure for every event after its allocation using init_stats() function. This initializes stats->min to -1 and makes 'Min time' statistics counting work: # perf kvm stat report Analyze events for all VCPUs: VM-EXIT Samples Samples% Time% Min Time Max Time Avg time [..] 0xB2 MSCH 12 0.07% 0.00% 6us 8us 7.31us ( +- 2.11% ) 0xB2 CHSC 12 0.07% 0.00% 7us 18us 9.39us ( +- 9.49% ) 0xB2 STPX 8 0.05% 0.00% 1us 2us 1.88us ( +- 7.18% ) 0xB2 STSI 7 0.04% 0.00% 1us 44us 16.49us ( +- 38.20% ) [..] Signed-off-by: Alexander Yarygin Signed-off-by: Christian Borntraeger Reviewed-by: David Ahern Link: http://lkml.kernel.org/r/1397053319-2130-3-git-send-email-borntraeger@de.ibm.com [ Fixing the perf examples changelog output ] Signed-off-by: Jiri Olsa --- tools/perf/builtin-kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 21c164b8f9d..0f1e5a2f6ad 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -404,6 +404,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key) } event->key = *key; + init_stats(&event->total.stats); return event; } -- cgit v1.2.3 From 922d0e4d9f042f68baea28e5b3bd7bb708875f2e Mon Sep 17 00:00:00 2001 From: Vladimir Nikulichev Date: Thu, 17 Apr 2014 08:27:01 -0700 Subject: perf tools: Adjust symbols in VDSO pert-report doesn't resolve function names in VDSO: $ perf report --stdio -g flat,0.0,15,callee --sort pid ... 8.76% 0x7fff6b1fe861 __gettimeofday ACE_OS::gettimeofday() ... In this case symbol values should be adjusted the same way as for executables, relocatable objects and prelinked libraries. After fix: $ perf report --stdio -g flat,0.0,15,callee --sort pid ... 8.76% __vdso_gettimeofday __gettimeofday ACE_OS::gettimeofday() Signed-off-by: Vladimir Nikulichev Tested-by: Namhyung Kim Reviewed-by: Adrian Hunter Link: http://lkml.kernel.org/r/969812.163009436-sendEmail@nvs Signed-off-by: Jiri Olsa --- tools/perf/util/symbol-elf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 3b7dbf51d4a..6864661a79d 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -6,6 +6,7 @@ #include #include "symbol.h" +#include "vdso.h" #include #include "debug.h" @@ -618,6 +619,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, GElf_Shdr shdr; ss->adjust_symbols = (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL || + is_vdso_map(dso->short_name) || elf_section_by_name(elf, &ehdr, &shdr, ".gnu.prelink_undo", NULL) != NULL); -- cgit v1.2.3 From ffa91880a992ec1aaee4b4f7c9ddffda0c277ba9 Mon Sep 17 00:00:00 2001 From: Adrien BAK Date: Fri, 18 Apr 2014 11:00:43 +0900 Subject: perf tools: Improve error reporting In the current version, when using perf record, if something goes wrong in tools/perf/builtin-record.c:375 session = perf_session__new(file, false, NULL); The error message: "Not enough memory for reading per file header" is issued. This error message seems to be outdated and is not very helpful. This patch proposes to replace this error message by "Perf session creation failed" I believe this issue has been brought to lkml: https://lkml.org/lkml/2014/2/24/458 although this patch only tackles a (small) part of the issue. Additionnaly, this patch improves error reporting in tools/perf/util/data.c open_file_write. Currently, if the call to open fails, the user is unaware of it. This patch logs the error, before returning the error code to the caller. Reported-by: Will Deacon Signed-off-by: Adrien BAK Link: http://lkml.kernel.org/r/1397786443.3093.4.camel@beast [ Reorganize the changelog into paragraphs ] [ Added empty line after fd declaration in open_file_write ] Signed-off-by: Jiri Olsa --- tools/perf/builtin-record.c | 2 +- tools/perf/util/data.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index eb524f91bff..8ce62ef7f6c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -374,7 +374,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) session = perf_session__new(file, false, NULL); if (session == NULL) { - pr_err("Not enough memory for reading perf file header\n"); + pr_err("Perf session creation failed.\n"); return -1; } diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 1fbcd8bdc11..55de44ecebe 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -86,10 +86,17 @@ static int open_file_read(struct perf_data_file *file) static int open_file_write(struct perf_data_file *file) { + int fd; + if (check_backup(file)) return -1; - return open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); + fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); + + if (fd < 0) + pr_err("failed to open %s : %s\n", file->path, strerror(errno)); + + return fd; } static int open_file(struct perf_data_file *file) -- cgit v1.2.3