* Tracing KVM with Systemtap @ 2010-09-08 13:20 Rayson Ho 2010-09-08 14:08 ` Stefan Hajnoczi 0 siblings, 1 reply; 10+ messages in thread From: Rayson Ho @ 2010-09-08 13:20 UTC (permalink / raw) To: kvm Hi all, I am a developer of Systemtap. I am looking into tracing KVM (the kernel part and QEMU) and also the KVM guests with Systemtap. I googled and found references to Xenprobes and xdt+dtrace, and I was wondering if someone is working on the dynamic tracing interface for KVM? I've read the KVM kernel code and I think some expensive operations (things that need to be trapped back to the host kernel - eg. loading of control registers on x86/x64) can be interesting spots for adding an SDT (static marker), and I/O operations performed for the guests can be useful information to collect. I know that KVM guests run like a userspace process and thus techniques for tracing Xen might be overkilled, and also gdb can be used to trace KVM guests. However, are that anything special I need to be aware of before I go further into the development of the Systemtap KVM probes? (Opinions / Suggestions / Criticisms welcome!) Thanks, Rayson ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-08 13:20 Tracing KVM with Systemtap Rayson Ho @ 2010-09-08 14:08 ` Stefan Hajnoczi 2010-09-20 13:19 ` Rayson Ho 0 siblings, 1 reply; 10+ messages in thread From: Stefan Hajnoczi @ 2010-09-08 14:08 UTC (permalink / raw) To: Rayson Ho; +Cc: kvm On Wed, Sep 8, 2010 at 2:20 PM, Rayson Ho <rho@redhat.com> wrote: > Hi all, > > I am a developer of Systemtap. I am looking into tracing KVM (the kernel > part and QEMU) and also the KVM guests with Systemtap. I googled and > found references to Xenprobes and xdt+dtrace, and I was wondering if > someone is working on the dynamic tracing interface for KVM? > > I've read the KVM kernel code and I think some expensive operations > (things that need to be trapped back to the host kernel - eg. loading of > control registers on x86/x64) can be interesting spots for adding an SDT > (static marker), and I/O operations performed for the guests can be > useful information to collect. > > I know that KVM guests run like a userspace process and thus techniques > for tracing Xen might be overkilled, and also gdb can be used to trace > KVM guests. However, are that anything special I need to be aware of > before I go further into the development of the Systemtap KVM probes? > > (Opinions / Suggestions / Criticisms welcome!) Hi Rayson, For the KVM kernel module Linux trace events are already used. For example, see arch/x86/kvm/trace.h and check out /sys/kernel/debug/tracing/events/kvm/*. There is a set of useful static trace points for vm_exit/vm_enter, pio, mmio, etc. For the KVM guest there is perf-kvm(1). This allows perf(1) to look up addresses inside the guest (kernel only?). It produces system-wide performance profiles including guests. Perhaps someone can comment on perf-kvm's full feature set and limitations? For QEMU userspace Prerna Saxena and I are proposing a static tracing patchset. It abstracts the trace backend (SystemTap, LTTng UST, DTrace, etc) from the actual tracepoints so that portability can be achieved. There is a built-in trace backend that has a basic feature set but isn't as fancy as SystemTap. I have implemented LTTng Userspace Tracer support, perhaps you'd like to add SystemTap/DTrace support with sdt.h? http://www.mail-archive.com/qemu-devel@nongnu.org/msg41323.html http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing_v3 Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-08 14:08 ` Stefan Hajnoczi @ 2010-09-20 13:19 ` Rayson Ho 2010-09-20 13:36 ` Stefan Hajnoczi 0 siblings, 1 reply; 10+ messages in thread From: Rayson Ho @ 2010-09-20 13:19 UTC (permalink / raw) To: Stefan Hajnoczi, kvm; +Cc: systemtap On Wed, 2010-09-08 at 15:08 +0100, Stefan Hajnoczi wrote: > Hi Rayson, > For the KVM kernel module Linux trace events are already used. For > example, see arch/x86/kvm/trace.h and check out > /sys/kernel/debug/tracing/events/kvm/*. There is a set of useful > static trace points for vm_exit/vm_enter, pio, mmio, etc. > > For the KVM guest there is perf-kvm(1). This allows perf(1) to look > up addresses inside the guest (kernel only?). It produces system-wide > performance profiles including guests. Perhaps someone can comment on > perf-kvm's full feature set and limitations? > > For QEMU userspace Prerna Saxena and I are proposing a static tracing > patchset. It abstracts the trace backend (SystemTap, LTTng UST, > DTrace, etc) from the actual tracepoints so that portability can be > achieved. There is a built-in trace backend that has a basic feature > set but isn't as fancy as SystemTap. I have implemented LTTng > Userspace Tracer support, perhaps you'd like to add SystemTap/DTrace > support with sdt.h? Thanks Stefan for the reply! I've looked at the tracing additions in QEMU, including the "Simple trace backend" (simpletrace.c) and the "tracetool" script, and I think the SystemTap version can be implemented in a straightforward way. One thing I was wondering, there seems to be not a lot of probes (except the examples?) in the QEMU code, are we expected to see more probes in the next release, or this work will be a long-term project that will not be added to the official QEMU code in the near future? (I believe if we can get the tracing framework integrated, then specific probes can be added on-demand -- but of course that is just my own opinion :-D ) Thanks, Rayson > > http://www.mail-archive.com/qemu-devel@nongnu.org/msg41323.html > http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing_v3 > > Stefan > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-20 13:19 ` Rayson Ho @ 2010-09-20 13:36 ` Stefan Hajnoczi 2010-09-21 12:58 ` Rayson Ho 0 siblings, 1 reply; 10+ messages in thread From: Stefan Hajnoczi @ 2010-09-20 13:36 UTC (permalink / raw) To: Rayson Ho; +Cc: kvm, systemtap, Prerna Saxena On Mon, Sep 20, 2010 at 2:19 PM, Rayson Ho <rho@redhat.com> wrote: > On Wed, 2010-09-08 at 15:08 +0100, Stefan Hajnoczi wrote: >> Hi Rayson, >> For the KVM kernel module Linux trace events are already used. For >> example, see arch/x86/kvm/trace.h and check out >> /sys/kernel/debug/tracing/events/kvm/*. There is a set of useful >> static trace points for vm_exit/vm_enter, pio, mmio, etc. >> >> For the KVM guest there is perf-kvm(1). This allows perf(1) to look >> up addresses inside the guest (kernel only?). It produces system-wide >> performance profiles including guests. Perhaps someone can comment on >> perf-kvm's full feature set and limitations? >> >> For QEMU userspace Prerna Saxena and I are proposing a static tracing >> patchset. It abstracts the trace backend (SystemTap, LTTng UST, >> DTrace, etc) from the actual tracepoints so that portability can be >> achieved. There is a built-in trace backend that has a basic feature >> set but isn't as fancy as SystemTap. I have implemented LTTng >> Userspace Tracer support, perhaps you'd like to add SystemTap/DTrace >> support with sdt.h? > > Thanks Stefan for the reply! > > I've looked at the tracing additions in QEMU, including the "Simple > trace backend" (simpletrace.c) and the "tracetool" script, and I think > the SystemTap version can be implemented in a straightforward way. > > One thing I was wondering, there seems to be not a lot of probes (except > the examples?) in the QEMU code, are we expected to see more probes in > the next release, or this work will be a long-term project that will not > be added to the official QEMU code in the near future? > > (I believe if we can get the tracing framework integrated, then specific > probes can be added on-demand -- but of course that is just my own > opinion :-D ) Right now there are few pre-defined probes ("trace events" in QEMU tracing speak). As I develop I try to be mindful of new ones I create and whether they would be generally useful. I intend to contribute more probes and hope others will too! Prerna is also looking at adding useful probes. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-20 13:36 ` Stefan Hajnoczi @ 2010-09-21 12:58 ` Rayson Ho 2010-09-21 13:33 ` Stefan Hajnoczi 0 siblings, 1 reply; 10+ messages in thread From: Rayson Ho @ 2010-09-21 12:58 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm, systemtap, Prerna Saxena On Mon, 2010-09-20 at 14:36 +0100, Stefan Hajnoczi wrote: > Right now there are few pre-defined probes ("trace events" in QEMU > tracing speak). As I develop I try to be mindful of new ones I create > and whether they would be generally useful. I intend to contribute > more probes and hope others will too! I am still looking at/hacking the QEMU code. I have looked at the following places in the code that I think can be useful to have statistics gathered: net.c qemu_deliver_packet(), etc - network statistics <CPU Arch>/op_helper.c global_cpu_lock(), tlb_fill() - lock & unlock, and TLB refill statistics balloon.c, hw/virtio-balloon.c - ballooning information. Besides the ballooning part, which I know what it is but don't fully understand how it works, the other parts can be implemented as Systemtap tapsets (~ "DTrace scripts") in the initial stage. I will see what other probes are useful for the end users. Also, are there developer documentations for KVM? (I googled but found a lot of presentations about KVM but not a lot of info about the internals.) Rayson > > Prerna is also looking at adding useful probes. > > Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-21 12:58 ` Rayson Ho @ 2010-09-21 13:33 ` Stefan Hajnoczi 2010-09-22 12:11 ` Rayson Ho 0 siblings, 1 reply; 10+ messages in thread From: Stefan Hajnoczi @ 2010-09-21 13:33 UTC (permalink / raw) To: Rayson Ho; +Cc: kvm, systemtap, Prerna Saxena On Tue, Sep 21, 2010 at 1:58 PM, Rayson Ho <rho@redhat.com> wrote: > On Mon, 2010-09-20 at 14:36 +0100, Stefan Hajnoczi wrote: >> Right now there are few pre-defined probes ("trace events" in QEMU >> tracing speak). As I develop I try to be mindful of new ones I create >> and whether they would be generally useful. I intend to contribute >> more probes and hope others will too! > > I am still looking at/hacking the QEMU code. I have looked at the > following places in the code that I think can be useful to have > statistics gathered: > > net.c qemu_deliver_packet(), etc - network statistics Yes. > <CPU Arch>/op_helper.c global_cpu_lock(), tlb_fill() - lock & unlock, > and TLB refill statistics These are not relevant to KVM, they are only used when running with KVM disabled (TCG mode). > balloon.c, hw/virtio-balloon.c - ballooning information. Prerna added a balloon event which is in qemu.git trace-events. Does that one do what you need? > I will see what other probes are useful for the end users. Also, are > there developer documentations for KVM? (I googled but found a lot of > presentations about KVM but not a lot of info about the internals.) Not really. I suggest grabbing the source and following vl.c:main() to the main KVM execution code. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-21 13:33 ` Stefan Hajnoczi @ 2010-09-22 12:11 ` Rayson Ho 2010-09-22 12:33 ` Stefan Hajnoczi 0 siblings, 1 reply; 10+ messages in thread From: Rayson Ho @ 2010-09-22 12:11 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm, systemtap, Prerna Saxena On Tue, 2010-09-21 at 14:33 +0100, Stefan Hajnoczi wrote: > > net.c qemu_deliver_packet(), etc - network statistics > > Yes. Further digging into the code in the net/ directory, there are more functions that should be traced/probed - e.g. a lot of the net_socket* routines. Given that SystemTap, LTTng, and DTrace have extremely close to zero overhead at each probe point, adding them into code can provide users different performance resolutions into the networking code. > > <CPU Arch>/op_helper.c global_cpu_lock(), tlb_fill() - lock & unlock, > > and TLB refill statistics > > These are not relevant to KVM, they are only used when running with > KVM disabled (TCG mode). Hmm, while my main objective is to add probes for KVM, if they are useful to QEMU, I may as well add them to my patch. > > balloon.c, hw/virtio-balloon.c - ballooning information. > > Prerna added a balloon event which is in qemu.git trace-events. Does > that one do what you need? Thanks for the info. > > I will see what other probes are useful for the end users. Also, are > > there developer documentations for KVM? (I googled but found a lot of > > presentations about KVM but not a lot of info about the internals.) > > Not really. I suggest grabbing the source and following vl.c:main() > to the main KVM execution code. I was looking for the hardware interfacing code earlier this morning -- QEMU has the hardware specific directories (e.g. target-i386/ , target-ppc/ ), and I was trying to understand the execution environment when the host and guest are running on the same architecture. I believe cpu_gen_code() and other related functions are what I should dig into... Rayson > > Stefan > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-22 12:11 ` Rayson Ho @ 2010-09-22 12:33 ` Stefan Hajnoczi 2010-09-22 12:42 ` Rayson Ho 0 siblings, 1 reply; 10+ messages in thread From: Stefan Hajnoczi @ 2010-09-22 12:33 UTC (permalink / raw) To: Rayson Ho; +Cc: kvm, systemtap, Prerna Saxena On Wed, Sep 22, 2010 at 1:11 PM, Rayson Ho <rho@redhat.com> wrote: > On Tue, 2010-09-21 at 14:33 +0100, Stefan Hajnoczi wrote: >> > I will see what other probes are useful for the end users. Also, are >> > there developer documentations for KVM? (I googled but found a lot of >> > presentations about KVM but not a lot of info about the internals.) >> >> Not really. I suggest grabbing the source and following vl.c:main() >> to the main KVM execution code. > > I was looking for the hardware interfacing code earlier this morning -- > QEMU has the hardware specific directories (e.g. target-i386/ , > target-ppc/ ), and I was trying to understand the execution environment > when the host and guest are running on the same architecture. > > I believe cpu_gen_code() and other related functions are what I should > dig into... KVM does not generate code. Almost all the "emulation" code in the source tree is part of the Tiny Code Generator (TCG) used when KVM is not enabled (e.g. to emulate an ARM board on an x86-64 host). If you follow the life-cycle in vl.c it will take you through cpus.c and into kvm-all.c:kvm_cpu_exec(). Note that the details differ slightly between qemu.git and qemu-kvm.git, and I have described qemu.git. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-22 12:33 ` Stefan Hajnoczi @ 2010-09-22 12:42 ` Rayson Ho 2010-09-22 13:39 ` Stefan Hajnoczi 0 siblings, 1 reply; 10+ messages in thread From: Rayson Ho @ 2010-09-22 12:42 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm, systemtap, Prerna Saxena On Wed, 2010-09-22 at 13:33 +0100, Stefan Hajnoczi wrote: > KVM does not generate code. Almost all the "emulation" code in the > source tree is part of the Tiny Code Generator (TCG) used when KVM is > not enabled (e.g. to emulate an ARM board on an x86-64 host). Thanks, that's what I thought too. Otherwise it would be really slow to run KVM :) But if KVM is not used, and QEMU host & guest are running on the same architecture, is TCG off? (Hmm, I guess I can find that answer myself by reading the code). Stefan, are you accepting patches? If so, I will create a patch with the Systemtap framework & other probes. Rayson > > If you follow the life-cycle in vl.c it will take you through cpus.c > and into kvm-all.c:kvm_cpu_exec(). Note that the details differ > slightly between qemu.git and qemu-kvm.git, and I have described > qemu.git. > > Stefan > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tracing KVM with Systemtap 2010-09-22 12:42 ` Rayson Ho @ 2010-09-22 13:39 ` Stefan Hajnoczi 0 siblings, 0 replies; 10+ messages in thread From: Stefan Hajnoczi @ 2010-09-22 13:39 UTC (permalink / raw) To: Rayson Ho; +Cc: kvm, systemtap, Prerna Saxena On Wed, Sep 22, 2010 at 1:42 PM, Rayson Ho <rho@redhat.com> wrote: > On Wed, 2010-09-22 at 13:33 +0100, Stefan Hajnoczi wrote: >> KVM does not generate code. Almost all the "emulation" code in the >> source tree is part of the Tiny Code Generator (TCG) used when KVM is >> not enabled (e.g. to emulate an ARM board on an x86-64 host). > > Thanks, that's what I thought too. Otherwise it would be really slow to > run KVM :) > > But if KVM is not used, and QEMU host & guest are running on the same > architecture, is TCG off? (Hmm, I guess I can find that answer myself by > reading the code). TCG is unused when KVM is enabled. There has been discussion about building without it for KVM-only builds and qemu-kvm.git can do that today with a ./configure option. > Stefan, are you accepting patches? If so, I will create a patch with the > Systemtap framework & other probes. I am not a qemu.git or qemu-kvm.git committer but I review patches in areas that I work in, like tracing. I'll be happy to give you feedback. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-09-22 13:39 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-09-08 13:20 Tracing KVM with Systemtap Rayson Ho 2010-09-08 14:08 ` Stefan Hajnoczi 2010-09-20 13:19 ` Rayson Ho 2010-09-20 13:36 ` Stefan Hajnoczi 2010-09-21 12:58 ` Rayson Ho 2010-09-21 13:33 ` Stefan Hajnoczi 2010-09-22 12:11 ` Rayson Ho 2010-09-22 12:33 ` Stefan Hajnoczi 2010-09-22 12:42 ` Rayson Ho 2010-09-22 13:39 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox