From patchwork Mon Jan 31 21:51:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 81246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 98A7DB70E3 for ; Tue, 1 Feb 2011 09:54:05 +1100 (EST) Received: from localhost ([127.0.0.1]:51332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pk1gw-0001ea-Ba for incoming@patchwork.ozlabs.org; Mon, 31 Jan 2011 16:53:46 -0500 Received: from [140.186.70.92] (port=42963 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pk1ew-0001bi-RT for qemu-devel@nongnu.org; Mon, 31 Jan 2011 16:51:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pk1em-0004dt-8O for qemu-devel@nongnu.org; Mon, 31 Jan 2011 16:51:33 -0500 Received: from mail-yx0-f173.google.com ([209.85.213.173]:48996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pk1el-0004dS-W2 for qemu-devel@nongnu.org; Mon, 31 Jan 2011 16:51:32 -0500 Received: by mail-yx0-f173.google.com with SMTP id 31so2444455yxl.4 for ; Mon, 31 Jan 2011 13:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=maANarheBcdt9/baQroeiH+ZxPBFwGhsPb0REw9uhJM=; b=W5x9W85p4hpn1u60haD4C86ysGIP+HUEyZDuqp3NX9WZIKMo1f74GcdA/vlwsZcLW9 tsETLyNhtqeAwNnpyWqDn4FvI2h8eQY7xLirV34YXot6I2Lv8FMllHNeuYiIIwqD9yfq 6vSq374tTJD9HGjOANpD+i5htkG1359GmKC5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=J+AslSpYhUrl1A6e26Sz4ygjAp2MzmFg6D7SaNfHKREBRZlf8rhL20i/2WrVp+QVb6 OpwqT33VeC2Welp+tDGTTXRhjBQY9w1hELdWVXhUZFlYuo/wEDWSPAPqq504EIbYoopT KENgET/Hcwh4xJImdVsGrpuEsMxYBjeYMgRdc= Received: by 10.91.67.4 with SMTP id u4mr9627372agk.126.1296510691209; Mon, 31 Jan 2011 13:51:31 -0800 (PST) Received: from localhost.localdomain (93-34-149-100.ip50.fastwebnet.it [93.34.149.100]) by mx.google.com with ESMTPS id f10sm26376976anh.5.2011.01.31.13.51.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 31 Jan 2011 13:51:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 31 Jan 2011 22:51:18 +0100 Message-Id: <1296510679-12268-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296510679-12268-1-git-send-email-pbonzini@redhat.com> References: <1296510679-12268-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.173 Cc: Jan Kiszka Subject: [Qemu-devel] [PATCH 2/3] Correct alarm deadline computation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When the QEMU_CLOCK_HOST clock was added, computation of its deadline was added to qemu_next_deadline, which is correct but incomplete. I noticed this by reading the very convoluted rules whereby qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST when use_icount is true. This patch inlines qemu_next_deadline into qemu_next_deadline_dyntick, and then corrects the logic to skip only QEMU_CLOCK_VIRTUAL when use_icount is true. Signed-off-by: Paolo Bonzini Cc: Jan Kiszka --- qemu-timer.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 60283a8..c19d0a2 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -724,11 +724,18 @@ static uint64_t qemu_next_deadline_dyntick(void) int64_t delta; int64_t rtdelta; - if (use_icount) + if (!use_icount && active_timers[QEMU_CLOCK_VIRTUAL]) { + delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time - + qemu_get_clock(vm_clock); + } else { delta = INT32_MAX; - else - delta = qemu_next_deadline(); - + } + if (active_timers[QEMU_CLOCK_HOST]) { + int64_t hdelta = active_timers[QEMU_CLOCK_HOST]->expire_time - + qemu_get_clock(host_clock); + if (hdelta < delta) + delta = hdelta; + } if (active_timers[QEMU_CLOCK_REALTIME]) { rtdelta = (active_timers[QEMU_CLOCK_REALTIME]->expire_time - qemu_get_clock_ns(rt_clock));