From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [RFC: 0/2] patch for QEMU HPET periodic timer emulation to alleviate time drift Date: Thu, 03 Feb 2011 16:28:26 +0100 Message-ID: <4D4AC99A.2070803@siemens.com> References: <480481933.225059.1296734409954.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> <1375835067.226263.1296740625327.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: kvm , Glauber Costa , Avi Kivity , qemu-devel To: Ulrich Obergfell Return-path: Received: from thoth.sbs.de ([192.35.17.2]:33748 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880Ab1BCP2m (ORCPT ); Thu, 3 Feb 2011 10:28:42 -0500 In-Reply-To: <1375835067.226263.1296740625327.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-02-03 14:43, Ulrich Obergfell wrote: > > Hi, > > I am observing severe backward time drift in a MS Windows Vista(tm) > guest running on a Fedora 14 KVM host. I can reproduce the problem > with the following steps: > > 1. Use 'vncviewer' to connect to the guest's desktop. > 2. Click on the menu title bar of a window on the guest's desktop. > 3. Move that window around on the guest's desktop. > > While I keep on moving the window around for one minute, the guest > time falls up to 15 seconds behind host time. > > The problem is caused by delayed callbacks of hpet_timer(). A timer > interrupt is injected into the guest during each callback. However, > interrupts are lost if delays are greater than a comparator period. > Yes, that's a well known limitation of qemu, in fact. We are lacking a generic irq coalescing infrastructure. That, once designed and available, would also allow to fix the HPET. > > This is an RFC through which I would like to get feedback on how the > idea of a patch to compensate those lost interrupts would be received: > > The patch determines the number of lost timer interrupts based on the > number of elapsed comparator periods. Lost interrupts are compensated That neglects coalescing of the HPET IRQs: If the timer is run regularly but the guest is not able to retrieve the injected IRQs, you should still see drifts with your patches. > by gradually injecting additional interrupts during the subsequent > timer intervals, starting at a rate of one additional interrupt per > interval. If further interrupts are lost while compensation is still > in progress, the rate is increased. The algorithm imposes a limit on > the rate and on the 'backlog' of lost interrupts to be injected. The > patch can be enabled via a qemu command line option. > > -hpet [device=none|present][,driftfix=none|slew] > > The 'device=none' option is equivalent to the '-no-hpet' option, and > the 'driftfix=slew' option enables the patch (similar to RTC). > > > The second and third part of this series of email contain the patch: > > - Code part 1 introduces the qemu command line option. > - Code part 2 implements compensation of lost interrupts. > > Please review and please comment. > Generally, this issue needs to be attacked at qemu level (added to CC), not qemu-kvm. We had a lengthy discussion on the list last year. We (including qemu people) basically agreed that we needs a generic feedback infrastructure to track coalesced IRQs for periodic, clock providing devices to allow reinjection (which would include reinjection of completely missed timer events like in your series). However, there was one unsolved design issue remain IIRC: http://thread.gmane.org/gmane.comp.emulators.qemu/73181 Once we have a proper answer for this, we can resume creating the de-coalescing framework. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60017 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pl16m-00033I-08 for qemu-devel@nongnu.org; Thu, 03 Feb 2011 10:28:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pl16k-0006yd-Mk for qemu-devel@nongnu.org; Thu, 03 Feb 2011 10:28:31 -0500 Received: from thoth.sbs.de ([192.35.17.2]:31212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pl16k-0006yT-Cv for qemu-devel@nongnu.org; Thu, 03 Feb 2011 10:28:30 -0500 Message-ID: <4D4AC99A.2070803@siemens.com> Date: Thu, 03 Feb 2011 16:28:26 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <480481933.225059.1296734409954.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> <1375835067.226263.1296740625327.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> In-Reply-To: <1375835067.226263.1296740625327.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [RFC: 0/2] patch for QEMU HPET periodic timer emulation to alleviate time drift List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ulrich Obergfell Cc: Glauber Costa , Avi Kivity , kvm , qemu-devel On 2011-02-03 14:43, Ulrich Obergfell wrote: > > Hi, > > I am observing severe backward time drift in a MS Windows Vista(tm) > guest running on a Fedora 14 KVM host. I can reproduce the problem > with the following steps: > > 1. Use 'vncviewer' to connect to the guest's desktop. > 2. Click on the menu title bar of a window on the guest's desktop. > 3. Move that window around on the guest's desktop. > > While I keep on moving the window around for one minute, the guest > time falls up to 15 seconds behind host time. > > The problem is caused by delayed callbacks of hpet_timer(). A timer > interrupt is injected into the guest during each callback. However, > interrupts are lost if delays are greater than a comparator period. > Yes, that's a well known limitation of qemu, in fact. We are lacking a generic irq coalescing infrastructure. That, once designed and available, would also allow to fix the HPET. > > This is an RFC through which I would like to get feedback on how the > idea of a patch to compensate those lost interrupts would be received: > > The patch determines the number of lost timer interrupts based on the > number of elapsed comparator periods. Lost interrupts are compensated That neglects coalescing of the HPET IRQs: If the timer is run regularly but the guest is not able to retrieve the injected IRQs, you should still see drifts with your patches. > by gradually injecting additional interrupts during the subsequent > timer intervals, starting at a rate of one additional interrupt per > interval. If further interrupts are lost while compensation is still > in progress, the rate is increased. The algorithm imposes a limit on > the rate and on the 'backlog' of lost interrupts to be injected. The > patch can be enabled via a qemu command line option. > > -hpet [device=none|present][,driftfix=none|slew] > > The 'device=none' option is equivalent to the '-no-hpet' option, and > the 'driftfix=slew' option enables the patch (similar to RTC). > > > The second and third part of this series of email contain the patch: > > - Code part 1 introduces the qemu command line option. > - Code part 2 implements compensation of lost interrupts. > > Please review and please comment. > Generally, this issue needs to be attacked at qemu level (added to CC), not qemu-kvm. We had a lengthy discussion on the list last year. We (including qemu people) basically agreed that we needs a generic feedback infrastructure to track coalesced IRQs for periodic, clock providing devices to allow reinjection (which would include reinjection of completely missed timer events like in your series). However, there was one unsolved design issue remain IIRC: http://thread.gmane.org/gmane.comp.emulators.qemu/73181 Once we have a proper answer for this, we can resume creating the de-coalescing framework. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux