Re: [patch 4/4] KVM-trace port to tracepoints

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Thursday, July 17, 2008 - 10:28 am

* Jan Kiszka (jan.kiszka@siemens.com) wrote:

This LOC blow-up is caused by the creation of one probe per
instrumentation site. So instead of placing the argument setup of
everything that goes in the trace (0 to 5 u32 arguments) in the kvm
code, it can be placed separately in a probe object, which could
eventually be a dynamically loadable module.

The primary objective of tracepoints is to make sure the kernel code
does not become harder to read because of added instrumentation and to
provide type-checking at compile-time without needing to put format
strings into the kernel code, which, to some, looks like debugging code.
The other aspect it try to address is maintainability of trace points :
it's much easier to look at all the prototype definitions in
include/trace/*.h and to manage them (and external tracers which would
like to connect on those points) than to try to figure out in which C
files tracing statements has been hidden. We can think of it as a
standard tracing API providing a more or less stable list of kernel
tracepoints.

So, while KVMTRACE_?D() statements suits closely kvm-trace
specificities, it's useless to impose constraints such as splitting
unsigned longs into two u32 for tracers which can support a wider
variety of data types.

After refactoring the patch to put the probes in arch/x86/kvm, the
result is :

 arch/x86/kvm/Makefile           |    1
 arch/x86/kvm/kvm_trace_probes.c |  251 ++++++++++++++++++++++++++++++++++++++++
 arch/x86/kvm/vmx.c              |   38 ++----
 arch/x86/kvm/x86.c              |   43 ++----
 include/asm-x86/kvm_host.h      |    8 +
 include/trace/kvm.h             |   83 +++++++++++++
 virt/kvm/kvm_trace.c            |   93 ++++++--------
 7 files changed, 414 insertions(+), 103 deletions(-)

So actually, is it better to have less LOC which looks like this :

        KVMTRACE_5D(CPUID, vcpu, function,
                    (u32)kvm_register_read(vcpu, VCPU_REGS_RAX),
                    (u32)kvm_register_read(vcpu, VCPU_REGS_RBX),
                    (u32)kvm_register_read(vcpu, VCPU_REGS_RCX),
                    (u32)kvm_register_read(vcpu, VCPU_REGS_RDX), handler);


or more LOC looking like this :

include/trace/kvm.h:
DEFINE_TRACE(kvm_cpuid,
        TPPROTO(struct kvm_vcpu *vcpu, u32 function),
        TPARGS(vcpu, function));

arch/x86/kvm/x86.c:
        trace_kvm_cpuid(vcpu, function);

arch/x86/kvm/kvm_trace_probes.c:
static void probe_kvm_cpuid(struct kvm_vcpu *vcpu, u32 function)
{
        kvm_add_trace(KVM_TRC_CPUID, vcpu, 5,
                (u32 []){ function,
                        (u32)kvm_register_read(vcpu, VCPU_REGS_RAX),
                        (u32)kvm_register_read(vcpu, VCPU_REGS_RBX),
                        (u32)kvm_register_read(vcpu, VCPU_REGS_RCX),
                        (u32)kvm_register_read(vcpu, VCPU_REGS_RDX) });
}

int register_kvm_tracepoints(void)
{
   ...
   ret = register_trace_kvm_cpuid(probe_kvm_cpuid);
   WARN_ON(ret);
   ...
}

void unregister_kvm_tracepoints(void)
{
   ...
   unregister_trace_kvm_cpuid(probe_kvm_cpuid);
   ...
}

?

Notice that only a single line of code is inserted to the kernel code,
while all the rest sits outsite in a separated probe module. So I think
it's very important to distinguish between LOC which impair kernel code
readability and LOC which sit in their own sandbox.

Mathieu


-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 4/4] KVM-trace port to tracepoints, Mathieu Desnoyers, (Thu Jul 17, 8:57 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Jan Kiszka, (Thu Jul 17, 9:49 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Anthony Liguori, (Thu Jul 17, 9:52 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Mathieu Desnoyers, (Thu Jul 17, 10:04 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Mathieu Desnoyers, (Thu Jul 17, 10:28 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Jan Kiszka, (Tue Jul 22, 9:04 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Avi Kivity, (Tue Jul 22, 11:46 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Peter Zijlstra, (Wed Jul 23, 12:49 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Avi Kivity, (Wed Jul 23, 1:08 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Peter Zijlstra, (Wed Jul 23, 1:55 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Avi Kivity, (Wed Jul 23, 2:32 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Peter Zijlstra, (Wed Jul 23, 2:53 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Christoph Hellwig, (Wed Jul 23, 3:03 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Avi Kivity, (Wed Jul 23, 3:08 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Christoph Hellwig, (Wed Jul 23, 3:13 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Mathieu Desnoyers, (Wed Jul 23, 6:15 am)
Re: [patch 4/4] KVM-trace port to tracepoints, Mathieu Desnoyers, (Wed Jul 23, 6:20 am)