[PATCH v2 3/3] perf kvm: Fix output fields instead of 'trace' for perf kvm report on powerpc
From: Ravi Bangoria
Date: Fri Jan 22 2016 - 01:00:14 EST
commit d49dadea7862 ("perf tools: Make 'trace' or 'trace_fields' sort key
default for tracepoint events") makes 'trace' sort key as a default
while displaying report for tracepoint.
As tracepoint(kvm_hv:kvm_guest_exit) is used as a default event for
recording data, perf kvm report will display output as a list of
tracepoint hits and not with a normal report columns.
This patch will replace 'overhead,comm,dso,sym' fields instead of 'trace'
while displaying perf kvm report on powerpc.
Before applying patch:
$ ./perf kvm --guestkallsyms=guest.kallsyms --guestmodules=guest.modules report --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 181K of event 'kvm_hv:kvm_guest_exit'
# Event count (approx.): 181061
#
# Overhead Trace output
# ........ .................................................................................
#
0.02% VCPU 8: trap=HV_DECREMENTER pc=0xc000000000091924 msr=0x8000000000009032, ceded=0
0.00% VCPU 0: trap=HV_DECREMENTER pc=0xc000000000091924 msr=0x8000000000009032, ceded=0
0.00% VCPU 8: trap=HV_DECREMENTER pc=0x10005c7c msr=0x800000000280f032, ceded=0
0.00% VCPU 8: trap=HV_DECREMENTER pc=0x1001ef14 msr=0x800000000280f032, ceded=0
0.00% VCPU 8: trap=HV_DECREMENTER pc=0x3fff83398830 msr=0x800000000280f032, ceded=0
0.00% VCPU 8: trap=HV_DECREMENTER pc=0x3fff833a6fe4 msr=0x800000000280f032, ceded=0
0.00% VCPU 8: trap=HV_DECREMENTER pc=0x3fff833a7a64 msr=0x800000000280f032, ceded=0
After applying patch:
$ ./perf kvm --guestkallsyms=guest.kallsyms --guestmodules=guest.modules report --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 181K of event 'kvm_hv:kvm_guest_exit'
# Event count (approx.): 181061
#
# Overhead Command Shared Object Symbol
# ........ ....... ....................... ..............................
#
0.02% :57276 [guest.kernel.kallsyms] [g] .plpar_hcall_norets
0.00% :57274 [guest.kernel.kallsyms] [g] .plpar_hcall_norets
0.00% :57276 [guest.kernel.kallsyms] [g] .__copy_tofrom_user_power7
0.00% :57276 [guest.kernel.kallsyms] [g] ._atomic_dec_and_lock
0.00% :57276 [guest.kernel.kallsyms] [g] ._raw_spin_lock
0.00% :57276 [guest.kernel.kallsyms] [g] ._switch
0.00% :57276 [guest.kernel.kallsyms] [g] .bio_add_page
0.00% :57276 [guest.kernel.kallsyms] [g] .kmem_cache_alloc
Signed-off-by: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxxxxxxx>
---
changes in v2:
- Fixes output format of perf kvm report on powerpc
tools/perf/arch/powerpc/util/kvm.c | 30 ++++++++++++++++++++++++++++++
tools/perf/builtin-kvm.c | 23 +++++++++++++++++------
tools/perf/builtin.h | 3 +++
3 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/tools/perf/arch/powerpc/util/kvm.c b/tools/perf/arch/powerpc/util/kvm.c
index 317f29a..e5d88cc 100644
--- a/tools/perf/arch/powerpc/util/kvm.c
+++ b/tools/perf/arch/powerpc/util/kvm.c
@@ -8,11 +8,13 @@
*/
#include <linux/err.h>
+#include <string.h>
#include "../../../util/evsel.h"
#include "../../../util/evlist.h"
#include "../../../util/trace-event.h"
#include "../../../util/session.h"
#include "../../../util/util.h"
+#include "../../../builtin.h"
#define KVMPPC_EXIT "kvm_hv:kvm_guest_exit"
#define HV_DECREMENTER 2432
@@ -102,3 +104,31 @@ u8 arch__get_cpumode(const union perf_event *event, struct perf_evsel *evsel,
ret:
return cpumode;
}
+
+const char **arch__cmd_kvm_report_argv(const char *file_name, int argc,
+ int *rec_argc, const char **argv)
+{
+ int i = 0, j, arch_argc = 0;
+ const char **rec_argv;
+
+ if (perf_guest_only())
+ arch_argc = 2;
+
+ *rec_argc = argc + arch_argc + 2;
+ rec_argv = calloc(*rec_argc + 1, sizeof(char *));
+ rec_argv[i++] = strdup("report");
+ rec_argv[i++] = strdup("-i");
+ rec_argv[i++] = strdup(file_name);
+
+ if (arch_argc) {
+ rec_argv[i++] = strdup("-F");
+ rec_argv[i++] = strdup("overhead,comm,dso,sym");
+ }
+
+ for (j = 1; j < argc; j++, i++)
+ rec_argv[i] = argv[j];
+
+ BUG_ON(i != *rec_argc);
+
+ return rec_argv;
+}
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 4418d92..48455c9 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1480,22 +1480,33 @@ static int __cmd_record(const char *file_name, int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
}
-static int __cmd_report(const char *file_name, int argc, const char **argv)
+
+const char ** __weak arch__cmd_kvm_report_argv(const char *file_name, int argc,
+ int *rec_argc, const char **argv)
{
- int rec_argc, i = 0, j;
+ int i = 0, j;
const char **rec_argv;
- rec_argc = argc + 2;
- rec_argv = calloc(rec_argc + 1, sizeof(char *));
+ *rec_argc = argc + 2;
+ rec_argv = calloc(*rec_argc + 1, sizeof(char *));
rec_argv[i++] = strdup("report");
rec_argv[i++] = strdup("-i");
rec_argv[i++] = strdup(file_name);
for (j = 1; j < argc; j++, i++)
rec_argv[i] = argv[j];
- BUG_ON(i != rec_argc);
+ BUG_ON(i != *rec_argc);
+
+ return rec_argv;
+}
+
+static int __cmd_report(const char *file_name, int argc, const char **argv)
+{
+ int rec_argc;
+ const char **rec_argv = arch__cmd_kvm_report_argv(file_name, argc,
+ &rec_argc, argv);
- return cmd_report(i, rec_argv, NULL);
+ return cmd_report(rec_argc, rec_argv, NULL);
}
static int
diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h
index 3f871b5..2ac149b 100644
--- a/tools/perf/builtin.h
+++ b/tools/perf/builtin.h
@@ -41,4 +41,7 @@ extern int cmd_mem(int argc, const char **argv, const char *prefix);
extern int cmd_data(int argc, const char **argv, const char *prefix);
extern int find_scripts(char **scripts_array, char **scripts_path_array);
+
+extern const char **arch__cmd_kvm_report_argv(const char *file_name,
+ int argc, int *rec_argc, const char **argv);
#endif
--
2.1.4