From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Markus Armbruster <armbru-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: Performance monitoring units and KVM
Date: Thu, 31 Jan 2008 09:03:48 +0200 [thread overview]
Message-ID: <47A172D4.6040505@qumranet.com> (raw)
In-Reply-To: <87fxwfw0jn.fsf-A7mx1g9ivIOttUaS3K59qNi2O/JbrIOy@public.gmane.org>
Markus Armbruster wrote:
> Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> writes:
>
>
>> Markus Armbruster wrote:
>>
>>> System-wide profiling of the *virtual* machine is related to profiling
>>> just a process. That's hard. I guess building on Perfmon2 would make
>>> sense there, but as long as it's out of tree... Can we wait for it?
>>> If not, what then?
>>>
>>>
>>>
>> Give the guest access to the real PMU. Save them on every exit
>> (switching profiling off), and restore them on every entry (switching
>> profiling on). The only problem with this is that it is very cpu
>> model dependent, losing the hardware independence that virtual
>> machines have. If you are satisfied with the architectural
>> performance counters, then we even have hardware independence.
>>
>
> Saving and restoring the PMU is *slow* on most machines. Especially
> bad on machines where reading / writing a PMU register involves
> serializing instructions.
>
>
That is true. It will increase vmexit latencies by several microseconds.
> Want to try anyway?
>
If we want to support unmodified oprofile/VTune, we have to. I can't
judge how important it would be to users.
>
>
>>> The same ideas should work for KVM. The whole hypervisor headache
>>> just evaporates, of course. What remains is the host kernel routing
>>> samples to active guests (over virtio, I guess), and guests kernels
>>> receiving samples from there instead of the hardware PMU. In other
>>> words, the sample channel from the host becomes our virtual PMU for
>>> the guest. Which needs a driver for it. It's a weird PMU, because
>>> you can't program its performance counters. That's left to the host.
>>>
>>>
>> Is there really a requirement to profile several userspace programs,
>> on several guests, simultaneously? If not, passing through the PMU
>> will work best, with the additional advantage that guests will not
>> need modification (so you can run Windows with VTune, for example).
>>
>
> There are uses for both kinds of system-wide profiling.
>
>
Okay; we can do both. Pass-through should be quite simple.
>> If this three-tier profiling is actually needed, perhaps we can do all
>> recording on the host, but have an interface to let the guest
>> translate rip samples to something more meaningful. This might work
>> in this way:
>>
>> - oprofile on the host receives the pmu nmi
>> - oprofile calls a hook (placed there by kvm) when it sees that the
>> task is actually a virtual machine, instead of the usual translation
>> process
>> - kvm injects an interrupt into the guest
>> - the guest converts the pmu rip value into a meaningful string and
>> writes it into memory
>> - (later) kvm picks this up and passes it back to oprofile
>>
>> The advantage here is that besides a fairly simple driver that needs
>> to be loaded into the guest (and can be loaded automatically),
>> everything is controlled from the host. All the information is
>> available on the host, so that sorting by counter occurences, for
>> example, works.
>>
>
> Yep.
>
> Problems include:
>
> * OProfile user space receives dcookies from the kernel, which it
> passes to lookup_dcookie(). We'd have to delegate that to the
> appropriate guest.
>
This part looks doable.
> * OProfile user space needs to be taught where do find each guest's
> debug info.
>
This one seems too horrible to contemplate. NFS exports on each guest
and mounts on the host? With fuse sshfs?
Collecting and analyzing all the data on the host looks much better than
distributing it to guests, however, if we can manage to transfer the
debug information.
[Wild idea: rewrite lookup_dcookie in a systemtap-like language, and
execute it on the host instead of on the guest. Basically the host would
use the guest's vmlinux debug info to decode the information from raw
kernel memory]
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-01-31 7:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-30 17:06 Performance monitoring units and KVM Markus Armbruster
[not found] ` <87wsprxmyb.fsf-A7mx1g9ivIOttUaS3K59qNi2O/JbrIOy@public.gmane.org>
2008-01-30 17:41 ` Avi Kivity
[not found] ` <47A0B6DF.40208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 18:05 ` Andi Kleen
2008-01-30 18:23 ` Balaji Rao
[not found] ` <200801302353.19872.balajirrao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-01-30 18:14 ` Avi Kivity
[not found] ` <47A0BE8F.4090508-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 18:26 ` Andi Kleen
[not found] ` <p73ir1b5fvy.fsf-KvMlXPVkKihbpigZmTR7Iw@public.gmane.org>
2008-01-30 19:14 ` Balaji Rao
[not found] ` <200801310044.11055.balajirrao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-01-31 3:12 ` Andi Kleen
[not found] ` <20080131031232.GB27115-qrUzlfsMFqo/4alezvVtWx2eb7JE58TQ@public.gmane.org>
2008-01-31 3:44 ` Performance monitoring units and KVM II Andi Kleen
2008-01-31 7:12 ` Performance monitoring units and KVM Balaji Rao
2008-01-30 18:55 ` Balaji Rao
2008-01-30 19:55 ` Markus Armbruster
[not found] ` <87fxwfw0jn.fsf-A7mx1g9ivIOttUaS3K59qNi2O/JbrIOy@public.gmane.org>
2008-01-31 7:03 ` Avi Kivity [this message]
[not found] ` <47A172D4.6040505-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-31 15:42 ` Markus Armbruster
[not found] ` <87odb2gfx5.fsf-A7mx1g9ivIOttUaS3K59qNi2O/JbrIOy@public.gmane.org>
2008-01-31 16:37 ` Avi Kivity
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=47A172D4.6040505@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=armbru-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox