* kvm & dyntick
@ 2007-01-11 16:08 Avi Kivity
[not found] ` <45A66106.5030608-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2007-01-11 16:08 UTC (permalink / raw)
To: Ingo Molnar; +Cc: kvm-devel, linux-kernel
It occurs to me that kvm could benefit greatly from dyntick:
dyntick-enabled host:
- generate virtual interrupts at whatever HZ the guest programs its
timers, be it 100, 250, 1000 or whatever
- avoid expensive vmexits due to useless timer interrupts
dyntick-enabled guest:
- reduce the load on the host when the guest is idling
(currently an idle guest consumes a few percent cpu)
What are the current plans wrt dyntick? Is it planned for 2.6.21?
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread[parent not found: <45A66106.5030608-atKUWr5tajBWk0Htik3J/w@public.gmane.org>]
* Re: kvm & dyntick [not found] ` <45A66106.5030608-atKUWr5tajBWk0Htik3J/w@public.gmane.org> @ 2007-01-12 5:34 ` Rik van Riel 2007-01-12 6:20 ` Ingo Molnar 1 sibling, 0 replies; 9+ messages in thread From: Rik van Riel @ 2007-01-12 5:34 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-devel, linux-kernel Avi Kivity wrote: > dyntick-enabled guest: > - reduce the load on the host when the guest is idling > (currently an idle guest consumes a few percent cpu) You do not need dynticks for this actually. Simple no-tick-on-idle like Xen has works well enough. While you're modifying the timer code, you might also want to add proper accounting for steal time. Time during which your guest had a runnable process, but was not actually running itself, should not be accounted against the currently running process. I wonder if it would be possible to simply copy some of the timer code from Xen. They have the timing quirks worked out very well and their timer_interrupt() is pretty nice code. (Now I need to buy myself another VT box so I can help out with KVM :)) http://virt.kernelnewbies.org/ParavirtBenefits has some other features you may want to have :))) -- Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic. ------------------------------------------------------------------------- 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kvm & dyntick [not found] ` <45A66106.5030608-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 2007-01-12 5:34 ` Rik van Riel @ 2007-01-12 6:20 ` Ingo Molnar [not found] ` <20070112062006.GA32714-X9Un+BFzKDI@public.gmane.org> 1 sibling, 1 reply; 9+ messages in thread From: Ingo Molnar @ 2007-01-12 6:20 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-devel, linux-kernel * Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote: > It occurs to me that kvm could benefit greatly from dyntick: > > dyntick-enabled host: > - generate virtual interrupts at whatever HZ the guest programs its > timers, be it 100, 250, 1000 or whatever > - avoid expensive vmexits due to useless timer interrupts > > dyntick-enabled guest: > - reduce the load on the host when the guest is idling > (currently an idle guest consumes a few percent cpu) yeah. KVM under -rt already works with dynticks enabled on both the host and the guest. (but it's more optimal to use a dedicated hypercall to set the next guest-interrupt) > What are the current plans wrt dyntick? Is it planned for 2.6.21? yeah, we hope to have it in v2.6.21. note that s390 (and more recently Xen too) uses a next_timer_interrupt() based method to stop the guest tick - which works in terms of reducing guest load, but it doesnt stop the host-side interrupt. The highest quality approach is to have dynticks on both the host and the guest, and this also gives high-resolution timers and a modernized time/timer-events subsystem for both the host and the guest. Ingo ------------------------------------------------------------------------- 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20070112062006.GA32714-X9Un+BFzKDI@public.gmane.org>]
* Re: kvm & dyntick [not found] ` <20070112062006.GA32714-X9Un+BFzKDI@public.gmane.org> @ 2007-01-12 10:19 ` Ingo Molnar [not found] ` <20070112101931.GA11635-X9Un+BFzKDI@public.gmane.org> 2007-01-12 23:25 ` [kvm-devel] " Dor Laor 0 siblings, 2 replies; 9+ messages in thread From: Ingo Molnar @ 2007-01-12 10:19 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-devel, linux-kernel * Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org> wrote: > > dyntick-enabled guest: > > - reduce the load on the host when the guest is idling > > (currently an idle guest consumes a few percent cpu) > > yeah. KVM under -rt already works with dynticks enabled on both the > host and the guest. (but it's more optimal to use a dedicated > hypercall to set the next guest-interrupt) using the dynticks code from the -rt kernel makes the overhead of an idle guest go down by a factor of 10-15: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2556 mingo 15 0 598m 159m 157m R 1.5 8.0 0:26.20 qemu ( for this to work on my system i have added a 'hyper' clocksource hypercall API for KVM guests to use - this is needed instead of the running-to-slowly TSC. ) Ingo ------------------------------------------------------------------------- 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20070112101931.GA11635-X9Un+BFzKDI@public.gmane.org>]
* Re: kvm & dyntick [not found] ` <20070112101931.GA11635-X9Un+BFzKDI@public.gmane.org> @ 2007-01-12 17:04 ` Avi Kivity 2007-01-14 8:39 ` Ingo Molnar 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2007-01-12 17:04 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm-devel, linux-kernel Ingo Molnar wrote: > * Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org> wrote: > > >>> dyntick-enabled guest: >>> - reduce the load on the host when the guest is idling >>> (currently an idle guest consumes a few percent cpu) >>> >> yeah. KVM under -rt already works with dynticks enabled on both the >> host and the guest. (but it's more optimal to use a dedicated >> hypercall to set the next guest-interrupt) >> > > using the dynticks code from the -rt kernel makes the overhead of an > idle guest go down by a factor of 10-15: > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 2556 mingo 15 0 598m 159m 157m R 1.5 8.0 0:26.20 qemu > > As usual, great news. > ( for this to work on my system i have added a 'hyper' clocksource > hypercall API for KVM guests to use - this is needed instead of the > running-to-slowly TSC. ) > What's the problem with the TSC? The only issue I'm aware of is that the tsc might go backwards if the vcpu is migrated to another host cpu (easily fixed). A pv clocksource makes sense in any case. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kvm & dyntick 2007-01-12 17:04 ` Avi Kivity @ 2007-01-14 8:39 ` Ingo Molnar 0 siblings, 0 replies; 9+ messages in thread From: Ingo Molnar @ 2007-01-14 8:39 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-devel, linux-kernel, Thomas Gleixner * Avi Kivity <avi@qumranet.com> wrote: > >( for this to work on my system i have added a 'hyper' clocksource > > hypercall API for KVM guests to use - this is needed instead of the > > running-to-slowly TSC. ) > > > > What's the problem with the TSC? The only issue I'm aware of is that > the tsc might go backwards if the vcpu is migrated to another host cpu > (easily fixed). this is not a problem of KVM - this is a problem of this laptop: its TSC stops when going idle. So the TSC is fundamentally unusable for reliable timekeeping - and qemu doesnt offer pmtimer emulation to fall back to, so the dyntick kernel refused to go high-res under KVM. Once i added the hyper clocksource to fall back to, it could utilize the PIT and the lapic for clock-events. Ingo ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [kvm-devel] kvm & dyntick 2007-01-12 10:19 ` Ingo Molnar [not found] ` <20070112101931.GA11635-X9Un+BFzKDI@public.gmane.org> @ 2007-01-12 23:25 ` Dor Laor 2007-01-12 23:39 ` Thomas Gleixner 2007-01-14 8:51 ` Ingo Molnar 1 sibling, 2 replies; 9+ messages in thread From: Dor Laor @ 2007-01-12 23:25 UTC (permalink / raw) To: Ingo Molnar, Avi Kivity; +Cc: kvm-devel, linux-kernel >* Ingo Molnar <mingo@elte.hu> wrote: > >> > dyntick-enabled guest: >> > - reduce the load on the host when the guest is idling >> > (currently an idle guest consumes a few percent cpu) >> >> yeah. KVM under -rt already works with dynticks enabled on both the >> host and the guest. (but it's more optimal to use a dedicated >> hypercall to set the next guest-interrupt) > >using the dynticks code from the -rt kernel makes the overhead of an >idle guest go down by a factor of 10-15: > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 2556 mingo 15 0 598m 159m 157m R 1.5 8.0 0:26.20 qemu > >( for this to work on my system i have added a 'hyper' clocksource > hypercall API for KVM guests to use - this is needed instead of the > running-to-slowly TSC. ) > > Ingo This is great news for PV guests. Never-the-less we still need to improve our full virtualized guest support. First we need a mechanism (can we use the timeout_granularity?) to dynamically change the host timer frequency so we can support guests with 100hz that dynamically change their freq to 1000hz and back. Afterwards we'll need to compensate the lost alarm signals to the guests by using one of - hrtimers to inject the lost interrupts for specific guests. The problem this will increase the overall load. - Injecting several virtual irq to the guests one after another (using interrupt window exit). The question is how the guest will be effected from this unfair behavior. Can dyntick help HVMs? Will the answer be the same for guest-dense hosts? I understood that the main gain of dyn-tick is for idle time. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-devel] kvm & dyntick 2007-01-12 23:25 ` [kvm-devel] " Dor Laor @ 2007-01-12 23:39 ` Thomas Gleixner 2007-01-14 8:51 ` Ingo Molnar 1 sibling, 0 replies; 9+ messages in thread From: Thomas Gleixner @ 2007-01-12 23:39 UTC (permalink / raw) To: Dor Laor; +Cc: Ingo Molnar, Avi Kivity, kvm-devel, linux-kernel On Fri, 2007-01-12 at 15:25 -0800, Dor Laor wrote: > This is great news for PV guests. > > Never-the-less we still need to improve our full virtualized guest > support. Full virtualized guests, which have their own dyntick support, are fine as long as we provide local apic emulation for them. If a guest does not have that, it will use the periodic mode. There is no way to circumvent this. We do not know, whether the guest relies on that periodic interrupt or not. tglx ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-devel] kvm & dyntick 2007-01-12 23:25 ` [kvm-devel] " Dor Laor 2007-01-12 23:39 ` Thomas Gleixner @ 2007-01-14 8:51 ` Ingo Molnar 1 sibling, 0 replies; 9+ messages in thread From: Ingo Molnar @ 2007-01-14 8:51 UTC (permalink / raw) To: Dor Laor; +Cc: Avi Kivity, kvm-devel, linux-kernel * Dor Laor <dor.laor@qumranet.com> wrote: > Afterwards we'll need to compensate the lost alarm signals to the > guests by using one of > - hrtimers to inject the lost interrupts for specific guests. The > problem this will increase the overall load. > - Injecting several virtual irq to the guests one after another > (using interrupt window exit). The question is how the guest will be > effected from this unfair behavior. well, the most important thing would be to fix qemu to: - not use a 1024 /dev/rtc stream of signals as its clock emulation source i hacked that out of qemu, only to find out that qemu then uses periodic itimers. Instead of that it should use one-shot itimers, driven by the expiry time of the next clock. I.e. this code in vl.c, in host_alarm_handler(): if (qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL], qemu_get_clock(vm_clock)) || qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock))) { should start an itimer with an expiry time of: active_timers[QEMU_TIMER_VIRTUAL]->expire_time - qemu_get_clock(vm_clock) or: active_timers[QEMU_TIMER_REALTIME]->expire_time - qemu_get_clock(rt_clock) whichever is smaller. Furthermore, whenever timer->expire_time is changed in qemu_mod_timer(), this set-the-next-itimer-expiry-time code needs to be called. Would anyone like to try that? this will reduce the host Qemu wakeup rate from 1000-1100/sec to the guest's 4-5/sec wakeup rate - resulting in 0.01% CPU overhead from a single idle guest. Current unmodified Qemu causes 10-20% CPU overhead from a single idle guest. Ingo ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-01-14 8:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-11 16:08 kvm & dyntick Avi Kivity
[not found] ` <45A66106.5030608-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-01-12 5:34 ` Rik van Riel
2007-01-12 6:20 ` Ingo Molnar
[not found] ` <20070112062006.GA32714-X9Un+BFzKDI@public.gmane.org>
2007-01-12 10:19 ` Ingo Molnar
[not found] ` <20070112101931.GA11635-X9Un+BFzKDI@public.gmane.org>
2007-01-12 17:04 ` Avi Kivity
2007-01-14 8:39 ` Ingo Molnar
2007-01-12 23:25 ` [kvm-devel] " Dor Laor
2007-01-12 23:39 ` Thomas Gleixner
2007-01-14 8:51 ` Ingo Molnar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox