From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCy59-000610-IZ for qemu-devel@nongnu.org; Sun, 29 Jun 2008 10:40:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCy57-00060c-Ca for qemu-devel@nongnu.org; Sun, 29 Jun 2008 10:40:46 -0400 Received: from [199.232.76.173] (port=56764 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCy57-00060Z-3o for qemu-devel@nongnu.org; Sun, 29 Jun 2008 10:40:45 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:43821) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KCy56-0007Ag-Jl for qemu-devel@nongnu.org; Sun, 29 Jun 2008 10:40:44 -0400 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate03.web.de (Postfix) with ESMTP id D4954E1C5D5C for ; Sun, 29 Jun 2008 16:40:43 +0200 (CEST) Received: from [88.64.4.12] (helo=[192.168.1.198]) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1KCy55-0005xQ-00 for qemu-devel@nongnu.org; Sun, 29 Jun 2008 16:40:43 +0200 Message-ID: <48679EEB.7020500@web.de> Date: Sun, 29 Jun 2008 16:40:43 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20080629140120.5626.1590.stgit@gleb-debian.qumranet.com.qumranet.com> <20080629140225.5626.16864.stgit@gleb-debian.qumranet.com.qumranet.com> In-Reply-To: <20080629140225.5626.16864.stgit@gleb-debian.qumranet.com.qumranet.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig1B47CC24746B48B043821357" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH 2/3] Fix time drift problem under high load when PIT is in use. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1B47CC24746B48B043821357 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Gleb Natapov wrote: > Count the number of interrupts that was lost due to interrupt coalescin= g > and re-inject them back when possible. This fixes time drift problem wh= en > pit is used as a time source. >=20 > Signed-off-by: Gleb Natapov > --- >=20 > hw/i8254.c | 20 +++++++++++++++++++- > 1 files changed, 19 insertions(+), 1 deletions(-) >=20 > diff --git a/hw/i8254.c b/hw/i8254.c > index 4813b03..c4f0f46 100644 > --- a/hw/i8254.c > +++ b/hw/i8254.c > @@ -61,6 +61,8 @@ static PITState pit_state; > =20 > static void pit_irq_timer_update(PITChannelState *s, int64_t current_t= ime); > =20 > +static uint32_t pit_irq_coalesced; > + > static int pit_get_count(PITChannelState *s) > { > uint64_t d; > @@ -369,12 +371,28 @@ static void pit_irq_timer_update(PITChannelState = *s, int64_t current_time) > return; > expire_time =3D pit_get_next_transition_time(s, current_time); > irq_level =3D pit_get_out1(s, current_time); > - qemu_set_irq(s->irq, irq_level); > + if(irq_level) { > + if(!qemu_irq_raise(s->irq)) > + pit_irq_coalesced++; > + } else { > + qemu_irq_lower(s->irq); > + if(pit_irq_coalesced > 0) { > + if(qemu_irq_raise(s->irq)) > + pit_irq_coalesced--; > + qemu_irq_lower(s->irq); > + } > + } That's graspable for my poor brain: reinject one coalesced IRQ right after the falling edge of an in-time delivery... > + > #ifdef DEBUG_PIT > printf("irq_level=3D%d next_delay=3D%f\n", > irq_level, > (double)(expire_time - current_time) / ticks_per_sec); > #endif > + if(pit_irq_coalesced && expire_time !=3D -1) { > + uint32_t div =3D ((pit_irq_coalesced >> 10) & 0x7f) + 2; > + expire_time -=3D ((expire_time - current_time) / div); > + } > + =2E.. but could you comment on this algorithm? I think I got what it does= : splitting up the next regular period in short intervals. But there are a bit too many magic numbers involved. Where do they come from? What happens if pit_irq_coalesced becomes large (or: how large can it become without risking an IRQ storm on the guest)? A few comments would help, I guess. Thanks, Jan --------------enig1B47CC24746B48B043821357 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkhnnusACgkQniDOoMHTA+nojgCfcfUAs2d6qORHbMGhinjnJy7o mFAAn1MVgA+fAjrKWRw8NbyQAK+rSoTQ =rVsJ -----END PGP SIGNATURE----- --------------enig1B47CC24746B48B043821357--