From: Jan Kiszka <jan.kiszka@siemens.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: akpm@linux-foundation.org, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Avi Kivity <avi@qumranet.com>,
kvm@vger.kernel.org, "Feng(Eric) Liu" <eric.e.liu@intel.com>
Subject: Re: [patch 4/4] KVM-trace port to tracepoints
Date: Tue, 22 Jul 2008 18:04:08 +0200 [thread overview]
Message-ID: <488604F8.1040008@siemens.com> (raw)
In-Reply-To: <20080717172853.GB29855@Krystal>
Mathieu Desnoyers wrote:
> * Jan Kiszka (jan.kiszka@siemens.com) wrote:
>> Mathieu Desnoyers wrote:
>>> Port/cleanup of KVM-trace to tracepoints.
>>>
>>> Tracepoints allow dormat instrumentation, like the kernel markers, but also
>>> allows to describe the trace points in global headers so they can be easily
>>> managed. They also do not use format strings.
>>>
>>> Anything that would involve an action (dereference a pointer, vmcs read, ...)
>>> only required when tracing is placed in the probes created in kvm_trace.c
>>>
>>> This patch depends on the "Tracepoints" patch.
>>>
>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>>> CC: 'Peter Zijlstra' <peterz@infradead.org>
>>> CC: 'Feng(Eric) Liu' <eric.e.liu@intel.com>
>>> CC: Avi Kivity <avi@qumranet.com>
>>> CC: kvm@vger.kernel.org
>>> ---
>>> arch/x86/kvm/vmx.c | 38 ++---
>>> arch/x86/kvm/x86.c | 43 ++----
>>> include/trace/kvm.h | 83 ++++++++++++
>>> virt/kvm/kvm_trace.c | 336 +++++++++++++++++++++++++++++++++++++++++++--------
>>> 4 files changed, 398 insertions(+), 102 deletions(-)
>> Is it a specific property of KVM-trace that causes this LOC blow-up? Or
>> is this a generic side-effect of tracepoints?
>>
>> [ Hmm, hope I didn't missed too much of the tracepoint discussion... ]
>>
>
> 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.
That's true - as long as you don't have to add/remove/modify
tracepoints. I had to do this job in the past (not for KVM). Having 1
spot in 1 file (based on generic probes) would be handier in that case
than 5 spots in 3 files. But if the KVM tracepoints are considered
stable in their number and structure, that shouldn't be an issue here.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2008-07-22 16:05 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 15:57 [patch 0/4] Port KVM-trace to tracepoints Mathieu Desnoyers
2008-07-17 15:57 ` [patch 1/4] kvm move VMCS Encodings to system headers Mathieu Desnoyers
2008-07-17 15:57 ` [patch 2/4] kvm move VMCS read " Mathieu Desnoyers
2008-07-17 15:57 ` [patch 3/4] KVM move register read-write " Mathieu Desnoyers
2008-07-17 15:57 ` [patch 4/4] KVM-trace port to tracepoints Mathieu Desnoyers
2008-07-17 16:49 ` Jan Kiszka
2008-07-17 17:28 ` Mathieu Desnoyers
2008-07-22 16:04 ` Jan Kiszka [this message]
2008-07-22 18:46 ` Avi Kivity
2008-07-23 7:49 ` Peter Zijlstra
2008-07-23 8:08 ` Avi Kivity
2008-07-23 8:55 ` Peter Zijlstra
2008-07-23 9:32 ` Avi Kivity
2008-07-23 9:53 ` Peter Zijlstra
2008-07-23 13:15 ` Mathieu Desnoyers
2008-07-23 10:03 ` Christoph Hellwig
2008-07-23 10:08 ` Avi Kivity
2008-07-23 10:13 ` Christoph Hellwig
2008-07-23 13:20 ` Mathieu Desnoyers
2008-07-17 16:52 ` Anthony Liguori
2008-07-17 17:04 ` Mathieu Desnoyers
2008-07-22 18:42 ` [patch 0/4] Port KVM-trace " Avi Kivity
2008-07-22 19:16 ` Frank Ch. Eigler
2008-07-22 19:31 ` Avi Kivity
2008-07-22 19:54 ` Frank Ch. Eigler
2008-07-22 22:12 ` [patch 0/4] Port KVM-trace to tracepoints -> LTTng ? Mathieu Desnoyers
2008-07-27 10:11 ` Avi Kivity
2008-07-28 0:54 ` [RFC] LTTng merge plan Mathieu Desnoyers
2008-07-28 0:54 ` Mathieu Desnoyers
2008-07-29 16:18 ` Frank Ch. Eigler
2008-07-29 16:18 ` Frank Ch. Eigler
2008-07-29 17:01 ` Mathieu Desnoyers
2008-07-29 17:01 ` Mathieu Desnoyers
[not found] ` <20080729211543.GB17097@redhat.com>
2008-07-29 22:41 ` module-placed markers/tracepoints Mathieu Desnoyers
2008-07-29 23:01 ` Frank Ch. Eigler
2008-07-29 23:19 ` Mathieu Desnoyers
2008-07-30 1:40 ` Rusty Russell
2008-07-30 2:27 ` [PATCH] Module : call synchronize_sched() between module exit() and free Mathieu Desnoyers
2008-07-30 3:04 ` Rusty Russell
2008-07-30 4:05 ` Mathieu Desnoyers
2008-07-30 11:40 ` Frank Ch. Eigler
2008-07-30 14:09 ` Mathieu Desnoyers
2008-07-31 0:54 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=488604F8.1040008@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=akpm@linux-foundation.org \
--cc=avi@qumranet.com \
--cc=eric.e.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.