Received: from eggs.gnu.org ([2001:4830:134:3::10]:53539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9whE-0007Rt-6f for qemu-devel@nongnu.org; Thu, 15 Aug 2013 08:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9wh5-0005QB-Da for qemu-devel@nongnu.org; Thu, 15 Aug 2013 08:30:32 -0400 Received: from mail-ea0-x236.google.com ([2a00:1450:4013:c01::236]:53374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9wh5-0005Q0-7N for qemu-devel@nongnu.org; Thu, 15 Aug 2013 08:30:23 -0400 Received: by mail-ea0-f182.google.com with SMTP id o10so341835eaj.27 for ; Thu, 15 Aug 2013 05:30:22 -0700 (PDT) Date: Thu, 15 Aug 2013 14:30:19 +0200 From: Stefan Hajnoczi Message-ID: <20130815123019.GB32262@stefanha-thinkpad.redhat.com> References: <1376239405-4084-1-git-send-email-alex@alex.org.uk> <1376239405-4084-20-git-send-email-alex@alex.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1376239405-4084-20-git-send-email-alex@alex.org.uk> Subject: Re: [Qemu-devel] [RFC] [PATCHv10 19/31] aio / timers: Use all timerlists in icount warp calculations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Anthony Liguori , Jan Kiszka , qemu-devel@nongnu.org, liu ping fan , Stefan Hajnoczi , Paolo Bonzini , MORITA Kazutaka , rth@twiddle.net On Sun, Aug 11, 2013 at 05:43:13PM +0100, Alex Bligh wrote: > @@ -314,7 +314,18 @@ void qemu_clock_warp(QEMUClock *clock) > } > > vm_clock_warp_start = qemu_get_clock_ns(rt_clock); > - deadline = qemu_clock_deadline(vm_clock); > + /* We want to use the earliest deadline from ALL vm_clocks */ > + deadline = qemu_clock_deadline_ns_all(vm_clock); > + > + /* Maintain prior (possibly buggy) behaviour where if no deadline > + * was set (as there is no vm_clock timer) or it is more than > + * INT32_MAX nanoseconds ahead, we still use INT32_MAX > + * nanoseconds. > + */ > + if ((deadline < 0) || (deadline > INT32_MAX)) { > + deadline = INT32_MAX; > + } > + I see no value in a spurious wakeup if no deadline was set, but it's harmless. As for overflow, I don't really understand how INT32_MAX prevents overflow. If the base timer value we're adding to is already huge then INT32_MAX could still overflow it. > if (deadline > 0) { > /* > * Ensure the vm_clock proceeds even when the virtual CPU goes to > @@ -333,8 +344,8 @@ void qemu_clock_warp(QEMUClock *clock) > * packets continuously instead of every 100ms. > */ > qemu_mod_timer(icount_warp_timer, vm_clock_warp_start + deadline); > - } else { > - qemu_notify_event(); > + } else if (deadline == 0) { > + qemu_clock_notify(vm_clock); It seems this change is just for clarity: deadline can either be >0 or 0? I think a plain else statement is clearer and doesn't leave you wondering in what case this qemu_clock_notify() isn't taken.