From 20d3cbd75ef17b96dfb4f5f1600c0278d330f5ca Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Thu, 12 Jun 2014 22:10:03 -0400 Subject: [PATCH 1/7] tools lib traceevent: Report unknown VMX exit reasons with code Allows to parse the result even if the KVM plugin does not yet understand a specific exit code. Link: http://lkml.kernel.org/r/5207446F.1090703@web.de Acked-by: Namhyung Kim Signed-off-by: Jan Kiszka Signed-off-by: Steven Rostedt Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_kvm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 9e0e8c61b43b..3e6122067d67 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -240,9 +240,8 @@ static const char *find_exit_reason(unsigned isa, int val) for (i = 0; strings[i].val >= 0; i++) if (strings[i].val == val) break; - if (strings[i].str) - return strings[i].str; - return "UNKNOWN"; + + return strings[i].str; } static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, @@ -251,6 +250,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, unsigned long long isa; unsigned long long val; unsigned long long info1 = 0, info2 = 0; + const char *reason; if (pevent_get_field_val(s, event, "exit_reason", record, &val, 1) < 0) return -1; @@ -258,7 +258,11 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0) isa = 1; - trace_seq_printf(s, "reason %s", find_exit_reason(isa, val)); + reason = find_exit_reason(isa, val); + if (reason) + trace_seq_printf(s, "reason %s", reason); + else + trace_seq_printf(s, "reason UNKNOWN (%llu)", val); pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1); From 6f21037b3295d4ba20ad2cc7cd4073ec64440f8f Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Thu, 12 Jun 2014 22:10:04 -0400 Subject: [PATCH 2/7] tools lib traceevent: Factor out print_exit_reason in kvm plugin We will reuse it for nested vmexit tracepoints. Link: http://lkml.kernel.org/r/619c418c8af87f03027b8c8013b0443996605700.1388855989.git.jan.kiszka@web.de Acked-by: Namhyung Kim Signed-off-by: Jan Kiszka Signed-off-by: Steven Rostedt Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_kvm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 3e6122067d67..2d7d1d7df0a8 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -244,15 +244,14 @@ static const char *find_exit_reason(unsigned isa, int val) return strings[i].str; } -static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, - struct event_format *event, void *context) +static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, const char *field) { unsigned long long isa; unsigned long long val; - unsigned long long info1 = 0, info2 = 0; const char *reason; - if (pevent_get_field_val(s, event, "exit_reason", record, &val, 1) < 0) + if (pevent_get_field_val(s, event, field, record, &val, 1) < 0) return -1; if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0) @@ -263,6 +262,16 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, trace_seq_printf(s, "reason %s", reason); else trace_seq_printf(s, "reason UNKNOWN (%llu)", val); + return 0; +} + +static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + unsigned long long info1 = 0, info2 = 0; + + if (print_exit_reason(s, record, event, "exit_reason") < 0) + return -1; pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1); From ea092aeb6d4725048c5a46d1c9cbb4fea49b80b0 Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (Red Hat)" Date: Thu, 12 Jun 2014 22:10:05 -0400 Subject: [PATCH 3/7] tools lib traceevent: Add back in kvm plugins nested_vmexit events The nested vmexit events were removed from the backport from trace-cmd because they were considered buggy. They have since been updated in trace-cmd but are still missing from the traceevent library. Add back in the buggy version to be able to backport the fixes. Acked-by: Namhyung Kim Signed-off-by: Steven Rostedt Link: http://lkml.kernel.org/r/20140613021157.291421941@goodmis.org Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_kvm.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 2d7d1d7df0a8..0d437837569f 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -326,6 +326,35 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, return 0; } + +static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + unsigned long long val; + + pevent_print_num_field(s, " rip %0x016llx", event, "rip", record, 1); + + if (pevent_get_field_val(s, event, "exit_code", record, &val, 1) < 0) + return -1; + + trace_seq_printf(s, "reason %s", find_exit_reason(2, val)); + + pevent_print_num_field(s, " ext_inf1: %0x016llx", event, "exit_info1", record, 1); + pevent_print_num_field(s, " ext_inf2: %0x016llx", event, "exit_info2", record, 1); + pevent_print_num_field(s, " ext_int: %0x016llx", event, "exit_int_info", record, 1); + pevent_print_num_field(s, " ext_int_err: %0x016llx", event, "exit_int_info_err", record, 1); + + return 0; +} + +static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + pevent_print_num_field(s, " rip %0x016llx", event, "rip", record, 1); + + return kvm_nested_vmexit_inject_handler(s, record, event, context); +} + union kvm_mmu_page_role { unsigned word; struct { @@ -422,6 +451,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) pevent_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn", kvm_emulate_insn_handler, NULL); + pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit", + kvm_nested_vmexit_handler, NULL); + + pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject", + kvm_nested_vmexit_inject_handler, NULL); + pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page", kvm_mmu_get_page_handler, NULL); @@ -456,6 +491,12 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn", kvm_emulate_insn_handler, NULL); + pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit", + kvm_nested_vmexit_handler, NULL); + + pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject", + kvm_nested_vmexit_inject_handler, NULL); + pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page", kvm_mmu_get_page_handler, NULL); From 7f6e3635db39fb2400dc515192125e7b73258000 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Thu, 12 Jun 2014 22:10:06 -0400 Subject: [PATCH 4/7] tools lib traceevent: Fix and cleanup kvm_nested_vmexit tracepoints Fix several issues of kvm_nested_vmexit[_inject]: field width aren't supported with pevent_print, rip was printed twice/incorrectly, SVM ISA was hard-coded, we don't use ':' to separate field names. Link: http://lkml.kernel.org/r/8e6c02b22ea8136c139a91c69d6cc73b8c5c184b.1388855989.git.jan.kiszka@web.de Acked-by: Namhyung Kim Signed-off-by: Jan Kiszka Signed-off-by: Steven Rostedt Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_kvm.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 0d437837569f..0575e59c65f0 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -330,19 +330,13 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context) { - unsigned long long val; - - pevent_print_num_field(s, " rip %0x016llx", event, "rip", record, 1); - - if (pevent_get_field_val(s, event, "exit_code", record, &val, 1) < 0) + if (print_exit_reason(s, record, event, "exit_code") < 0) return -1; - trace_seq_printf(s, "reason %s", find_exit_reason(2, val)); - - pevent_print_num_field(s, " ext_inf1: %0x016llx", event, "exit_info1", record, 1); - pevent_print_num_field(s, " ext_inf2: %0x016llx", event, "exit_info2", record, 1); - pevent_print_num_field(s, " ext_int: %0x016llx", event, "exit_int_info", record, 1); - pevent_print_num_field(s, " ext_int_err: %0x016llx", event, "exit_int_info_err", record, 1); + pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1); + pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1); + pevent_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1); + pevent_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1); return 0; } @@ -350,7 +344,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_r static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context) { - pevent_print_num_field(s, " rip %0x016llx", event, "rip", record, 1); + pevent_print_num_field(s, "rip %lx ", event, "rip", record, 1); return kvm_nested_vmexit_inject_handler(s, record, event, context); } From a21e3a34bef9e9c177be61111ced23e71e25fd8a Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 13 Jun 2014 10:31:27 -0400 Subject: [PATCH 5/7] tools lib traceevent: Fix format in plugin_kvm The format field argument passed to the format in pevent_print_num_field() will be of type long long. That means that %ll must be used instead of %l. Acked-by: Namhyung Kim Reported-by: Namhyung Kim Signed-off-by: Steven Rostedt Link: http://lkml.kernel.org/r/20140613103127.1a9bdee7@gandalf.local.home Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 0575e59c65f0..88fe83dff7cd 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -344,7 +344,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_r static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context) { - pevent_print_num_field(s, "rip %lx ", event, "rip", record, 1); + pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1); return kvm_nested_vmexit_inject_handler(s, record, event, context); } From 24eda087ccbb32f556cb3f9f78be152312bf6cc4 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 12 Jun 2014 19:44:20 -0400 Subject: [PATCH 6/7] tools lib traceevent: Clean up format of args in cfg80211 plugin While synchronizing what's in trace-cmd vs what's in perf, I came across a change that was made when entering the cfg80211 plugin into the tools/lib/traceevent directory. The function prototype went from: static unsigned long long process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) to: static unsigned long long process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) I can understand the line break after the long long, but there's no reason to keep args on a separate line. Signed-off-by: Steven Rostedt Link: http://lkml.kernel.org/r/20140612194420.24073744@gandalf.local.home Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c index c066b25905f8..4592d8438318 100644 --- a/tools/lib/traceevent/plugin_cfg80211.c +++ b/tools/lib/traceevent/plugin_cfg80211.c @@ -5,8 +5,7 @@ #include "event-parse.h" static unsigned long long -process___le16_to_cpup(struct trace_seq *s, - unsigned long long *args) +process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) { uint16_t *val = (uint16_t *) (unsigned long) args[0]; return val ? (long long) le16toh(*val) : 0; From 1545d8aca9ac1cb3f503fb9c29543d539d99c7af Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 12 Jun 2014 20:41:44 -0400 Subject: [PATCH 7/7] tools lib traceevent: Clean up format of args in jbd2 plugin While synchronizing what's in trace-cmd vs what's in perf, I came across a change that was made when entering the jbd2 plugin into the tools/lib/traceevent directory. For example, one of the function prototypes went from: unsigned long long process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args) to: static unsigned long long process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args) I can understand the line break after the long long, but there's no reason to keep args on a separate line. Signed-off-by: Steven Rostedt Link: http://lkml.kernel.org/r/20140612204144.018410d4@gandalf.local.home Signed-off-by: Jiri Olsa --- tools/lib/traceevent/plugin_jbd2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 0db714c721be..5c23d5bd27ce 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c @@ -30,8 +30,7 @@ #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) static unsigned long long -process_jbd2_dev_to_name(struct trace_seq *s, - unsigned long long *args) +process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args) { unsigned int dev = args[0]; @@ -40,8 +39,7 @@ process_jbd2_dev_to_name(struct trace_seq *s, } static unsigned long long -process_jiffies_to_msecs(struct trace_seq *s, - unsigned long long *args) +process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args) { unsigned long long jiffies = args[0];