From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Casey Jeffery <kcjeffery-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: KVM and Perf Counters
Date: Wed, 10 Jan 2007 11:37:40 +0200 [thread overview]
Message-ID: <45A4B3E4.7090202@qumranet.com> (raw)
In-Reply-To: <cb6aceaa0701091726h7fe94bb3q73db49e43ff226ed-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Casey Jeffery wrote:
> I've tried out the last few versions of KVM and think it's great. It's
> much easier to use and understand than Xen and performance is
> surprisingly good.
>
> One of the things I'd like to do is modify it to allow PMI generation
> based on the Intel performance counter facilities. Specifically, I'd
> like to be able to pin a guest to a CPU, program one of the IA32_PMCx
> MSR's to a count, configure the LVT to deliver an NMI on overflow,
> enable the PERF_EVT_SELx, and use the hardware-based MSR save/restore
> area to disable counting in root mode and re-enable when entering
> non-root.
>
Ok. Note that there are two possible mutually exclusive uses for the
performance counters:
1. Allow the guest to program the performance counters as it sees fit,
for example to run oprofile internally.
2. Let the host control the performance counters, for stuff like
deterministic record/replay.
We should by default allow (1), with the option for (2). This is
somewhat similar to the hardware breakpoints, so you'd need some control
like KVM_DEBUG_GUEST to switch modes.
> The questions I have now are the following:
>
> 1. It looks like the MSR save/restore area is set up already for EFER
> MSR and I assume that adding IA32_PMCx and IA32_PERFEVTSEL to the
> vmx_msr_index[] array would be enough to save/restore them. Is that
> correct?
>
Yes.
> 2. I don't completely follow the code from vmx.c
>
> save_msrs(vcpu->host_msrs, vcpu->nmsrs);
>
This saves the host msrs to the host save area.
> load_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
>
vmx has a bug where it corrupts a couple of msrs, so we load the first
NR_BAD_MSRS explicitly.
> ...VMLAUNCH/RESUME etc. ...
>
This loads vcpu->nmsrs - NR_BAD_MSRS from the guest area.
> ....
> ...VMEXIT...
>
>
This saves vcpu->nmsrs - NR_BAD_MSRS into the guest area, and then loads
vcpu->nmsrs - NR_BAD_MSRS from the host area.
> save_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
> load_msrs(vcpu->host_msrs, NR_BAD_MSRS);
>
These two lines do the same for the vmx-incompatible msrs.
> Does this mean the MSR values to be loaded on VM exit are initialized
> before leaving root mode while the VM_entry_load / VM_exit_store area
> is not touched?
>
I'm not sure I understand the question, but host msrs are never saved
automatically, and there are a couple of msrs we load and save manually
for both host and guest.
> 3. Is it possible to attribute counter ticks solely to a given KVM
> guest process and avoid counting ticks from other processes? I assume
> this isn't a problem since a VM exit should occur if the KVM process
> were to be pulled off the CPU by the kernel to do a context switch.
>
Yes.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2007-01-10 9:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-10 1:26 KVM and Perf Counters Casey Jeffery
[not found] ` <cb6aceaa0701091726h7fe94bb3q73db49e43ff226ed-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-01-10 9:37 ` Avi Kivity [this message]
[not found] ` <45A4B3E4.7090202-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-01 15:43 ` Casey Jeffery
[not found] ` <cb6aceaa0702010743v7fba298y23e825ef1e706801-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-02-01 16:10 ` Dor Laor
[not found] ` <64F9B87B6B770947A9F8391472E032160A3F2298-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-02-01 17:44 ` Casey Jeffery
2007-02-01 16:15 ` Avi Kivity
[not found] ` <45C21211.3050509-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-01 19:28 ` Casey Jeffery
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=45A4B3E4.7090202@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=kcjeffery-Re5JQEeQqe8AvxtiuMwx3w@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