From patchwork Wed Sep 19 07:26:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 184942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BAB592C007D for ; Wed, 19 Sep 2012 17:26:35 +1000 (EST) Received: from localhost ([::1]:46054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEEg5-0000Hx-RV for incoming@patchwork.ozlabs.org; Wed, 19 Sep 2012 03:26:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEEfq-0008Nn-Jl for qemu-devel@nongnu.org; Wed, 19 Sep 2012 03:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEEfm-0004zK-F0 for qemu-devel@nongnu.org; Wed, 19 Sep 2012 03:26:18 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:52397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEEfm-0004y6-88 for qemu-devel@nongnu.org; Wed, 19 Sep 2012 03:26:14 -0400 Received: by wibhm2 with SMTP id hm2so3800519wib.10 for ; Wed, 19 Sep 2012 00:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=yoosppC4ndpKn5ius5psOpKIuiMG00FdKk6H/Bwpj7c=; b=FFC5l/QiLRpbi7+YCyZiID7uZHc7kHgT6Z8U20u+hOtD256Ge03YE5ToznpWx3kzl0 FcOh8mmAivMY74evxZCuMkcupBtkqgVFA8m49WPFVTTq+GYWV1x5/1XyhoBwkCs2vmQ8 RkDO1soieWy81nsvzi/Y2PNaakuFuVzMs6powY07qEBZMS8BuA4T7GMIdJdwV09dT2Ai +kFTAJvThvUNRMp7qcm3u3aG2wUOb9DfTXLJ02oK3t65ywal0GjsRvpeMRGdKX6N6KKN tLO+nXUpd97krKm4b6Mbwu64YK5R6bVxH8DXAQCIEWl5zwOUVPdYruxrDzh/rM76GO8J 1qsw== Received: by 10.216.255.18 with SMTP id i18mr1267271wes.45.1348039573367; Wed, 19 Sep 2012 00:26:13 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id l5sm3647022wix.5.2012.09.19.00.26.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 00:26:12 -0700 (PDT) Message-ID: <5059738E.5070004@redhat.com> Date: Wed, 19 Sep 2012 09:26:06 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Anthony Liguori References: <1348000626-16129-1-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1348000626-16129-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.175 Cc: Jan Kiszka , qemu-devel@nongnu.org, Peter Portante , Stefan Weil Subject: Re: [Qemu-devel] [PATCH] qemu-clock: add an alarm timer based on timerfd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Il 18/09/2012 22:37, Anthony Liguori ha scritto: > Unfortunately, there's a lot of Windows code in qemu-timer.c and main-loop.c > right now otherwise the refactoring would be trivial. I'll leave that for > another day. > > Cc: Paolo Bonzini > Cc: Jan Kiszka > Signed-off-by: Anthony Liguori > --- > Please note, this is lightly tested. Since this is such a fundamental change, > I'd like to do some performance analysis before committing but wanted to share > early. Looks good. I think Peter Portante tested something similar, and found no big difference between the two. But it's a good thing and, in my opinion, for non-timerfd OSes we should simply adjust the select() timeout and not bother with signals. I'm not sure if the same can be done for Windows, but I think it's possible as long as you keep the timeBeginPeriod/timeEndPeriod calls. As a start, Stefan, can you check if the win32 timer works for you with the calls added? Like this: Paolo diff --git a/qemu-timer.c b/qemu-timer.c index c7a1551..721c769 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -673,6 +673,10 @@ static int win32_start_timer(struct qemu_alarm_timer *t) HANDLE hTimer; BOOLEAN success; + timeGetDevCaps(&mm_tc, sizeof(mm_tc)); + + timeBeginPeriod(mm_tc.wPeriodMin); + /* If you call ChangeTimerQueueTimer on a one-shot timer (its period is zero) that has already expired, the timer is not updated. Since creating a new timer is relatively expensive, set a bogus one-hour @@ -688,6 +692,7 @@ static int win32_start_timer(struct qemu_alarm_timer *t) if (!success) { fprintf(stderr, "Failed to initialize win32 alarm timer: %ld\n", GetLastError()); + timeEndPeriod(mm_tc.wPeriodMin); return -1; } @@ -702,6 +707,7 @@ static void win32_stop_timer(struct qemu_alarm_timer *t) if (hTimer) { DeleteTimerQueueTimer(NULL, hTimer, NULL); } + timeEndPeriod(mm_tc.wPeriodMin); } static void win32_rearm_timer(struct qemu_alarm_timer *t,