From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Dong, Eddie" <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: Remove APIC lock
Date: Sat, 25 Aug 2007 17:44:54 +0300 [thread overview]
Message-ID: <46D04066.4060206@qumranet.com> (raw)
In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A01F84646-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
Dong, Eddie wrote:
>> What about preemption:
>>
>> - vcpu executes lapic code in qemu process context
>>
>
> Don't understand. LAPIC is in kernel, how can qemu access?
> If you mean qemu is calling APIC KVM syscall, then it already
> disabled preemption & take kvm->lock.
>
>
>
I meant qemu executes the KVM_VCPU_RUN ioctl. kvm->lock does not
disable preemption (it is a mutex).
Do we really take kvm->lock for local accesses? That's a significant
problem, much more than the timer.
>> - process is preempted
>> - timer fires, touches lapic code
>>
>
> See above.
>
>
>> Furthermore, I question the necessity of this. Taking a spinlock is a
>> couple dozen cycles on modern processors. Entering the guest is a
>> couple thousand. So what are we saving?
>>
>
> I am stuck, can u explain more? We didn't enter guest more than before.
>
>
What I'm saying is that the performance improvement is negligible,
because the VT switch dominates the time. Taking the lock is fast in
comparison.
However I do like the simplification that removing the lock brings.
>> (migrating the timer is a good thing though).
>>
>> A different approach might be to wake up the vcpu like we do for irr,
>> with kvm_vcpu_kick(), and let the timer code be handled in process
>> context, so no locks need be taken.
>>
>>
>
> This can be too, but will that be much efficient than timer migration?
> Usually the guest APIC timer is around 1ms, which means we have
> to VM Exit guest 1000HZ with cost of thousands of cycles each time.
> While the process migration can only happen at scheduler quantum
> (10ms?) and highly depend on the scheduler policy. I guess the cost
> of hrtimer migration won;t exceed 1000 cycles in modern processor.
> And today the migration cost is already exceeds hundreds of cycles,
> add this additional one won;t change many. So I think the cost using
> hrtimer migration is much cheap than kvm_vcpu_kick(), but I may miss
> something.
>
>
I meant in addition to timer migration (I really like the timer
migration part -- it's much more important than lock removal for
performance). kvm_vcpu_kick() is needed to wake up from halt, or if we
have races between the timer and task migration.
I'm thinking about something like the remote tlb flush logic:
- hrtimer callback sets a bit in vcpu->requests and calls kvm_vcpu_kick().
- if the hrtimer and the vcpu are co-located, kvm_vcpu_kick() does
nothing
- if the guest is running on another cpu, it sends an IPI
- if the vcpu is halted, it wakes it up
- when we reenter the guest again, we examine vcpu->requests; if
KVM_REQ_LAPIC is set we know the timer expired and we run the lapic code
(where we can examine the pending count).
- we also need to update hlt sleep to look at vcpu->requests
So, to summarize:
- timer migration always helps, regardless of what we do
- lock removal helps, IMO, not performance, but stability and maintainablity
- kvm is preemptible except in vcpu_load() and guest entry, so if we do
lock removal we need to do everything in task context (nothing in
interrupts except raising bits like irr)
Opinions?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-08-25 14:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-24 13:08 Remove APIC lock Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01F84594-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-25 8:05 ` Avi Kivity
[not found] ` <46CFE2C6.5020006-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-25 14:16 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01F84646-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-25 14:44 ` Avi Kivity [this message]
[not found] ` <46D04066.4060206-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-25 15:14 ` Avi Kivity
2007-08-25 15:25 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01F8464D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-25 15:54 ` Avi Kivity
[not found] ` <46D050AB.2000900-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-26 23:41 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01F846D6-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-27 0:30 ` Avi Kivity
[not found] ` <46D21B37.8030106-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-27 1:54 ` Dong, Eddie
2007-09-03 13:48 ` Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2007-08-24 13:47 Gregory Haskins
[not found] ` <1187963266.4231.0.camel-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-08-24 13:55 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A01F845A5-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-24 14:24 ` Dong, Eddie
2007-08-24 14:39 ` Gregory Haskins
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=46D04066.4060206@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=eddie.dong-ral2JQCrhuEAvxtiuMwx3w@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