Re: [PATCH 6/7] KVM: x86: Use common definition for kvm_nested_vmexit tracepoint

From: Steven Rostedt
Date: Tue Jul 21 2020 - 17:42:38 EST


On Tue, 21 Jul 2020 12:31:30 -0700
Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote:

> +Steve
>
> Background: KVM has two tracepoints that effectively trace the same thing
> (VM-Exit vs. nested VM-Exit), but use completely different formatting and
> nomenclature for each of the existing tracepoints. I want to add a common
> macro to create the tracepoints so that they capture the exact same info
> and report it with the exact same format. But that means breaking the
> "ABI" for one of the tracepoints, e.g. trace-cmd barfs on the rename of
> exit_code to exit_reason.

Feel free to update it.

>
> Was there ever a verdict on whether or not tracepoints are considered ABI
> and thus must retain backwards compatibility?
>
> If not, what's the proper way to upstream changes to trace-cmd?
>

There's a kvm plugin in the libtraceevent code.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/traceevent/plugins/plugin_kvm.c

This overrides how the events are read. In the callback handler
(e.g. kvm_nested_vmexit_handle()), you can test if "rip" is there or
not. If it is not, you can do something different. For example:

struct tep_format_field *field;

field = tep_find_any_field(event, "rip");
if (field) {
tep_print_num_field(s, "rip %llx ", event, "rip", record, 1)
[..]
} else {
/* do something new */
}

You can test if fields exist and have the plugins do different things
depending on the format of an event. This is what I do in case an event
changes in the future.

-- Steve