From patchwork Fri May 29 15:14:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor CLEMENT X-Patchwork-Id: 477953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7E0B4140E61 for ; Sat, 30 May 2015 01:16:24 +1000 (AEST) Received: from localhost ([::1]:36607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyM1G-0005Z4-JU for incoming@patchwork.ozlabs.org; Fri, 29 May 2015 11:16:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyLzG-0002Bw-Vh for qemu-devel@nongnu.org; Fri, 29 May 2015 11:14:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyLzD-0007Pm-5K for qemu-devel@nongnu.org; Fri, 29 May 2015 11:14:18 -0400 Received: from zimbra3.corp.accelance.fr ([2001:4080:204::2:8]:53905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyLzC-0007PK-TD for qemu-devel@nongnu.org; Fri, 29 May 2015 11:14:15 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra3.corp.accelance.fr (Postfix) with ESMTP id 731507DD60; Fri, 29 May 2015 17:14:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra3.corp.accelance.fr Received: from zimbra3.corp.accelance.fr ([127.0.0.1]) by localhost (zimbra3.corp.accelance.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1CS76uDlXJBJ; Fri, 29 May 2015 17:14:13 +0200 (CEST) Received: from vicx-dell.daviel.openwide.fr. (bob75-2-81-56-46-209.fbx.proxad.net [81.56.46.209]) by zimbra3.corp.accelance.fr (Postfix) with ESMTPSA id 4DF5A7DD5C; Fri, 29 May 2015 17:14:13 +0200 (CEST) From: Victor CLEMENT To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 17:14:05 +0200 Message-Id: <1432912446-9811-3-git-send-email-victor.clement@openwide.fr> X-Mailer: git-send-email 2.4.2 In-Reply-To: <1432912446-9811-1-git-send-email-victor.clement@openwide.fr> References: <1432912446-9811-1-git-send-email-victor.clement@openwide.fr> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4080:204::2:8 Cc: francois.guerret@hotmail.fr, pbonzini@redhat.com, Victor CLEMENT , julien.viarddegalbert@openwide.fr Subject: [Qemu-devel] [PATCH v2 2/3] icount: add sleep parameter to the icount option to set icount_sleep mode 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 The 'sleep' parameter sets the icount_sleep mode, which is enabled by default. To disable it, add the 'sleep=no' parameter (or 'nosleep') to the qemu -icount option. Signed-off-by: Victor CLEMENT --- cpus.c | 9 +++++++++ qemu-options.hx | 12 ++++++++++-- vl.c | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 688eb73..4e90e63 100644 --- a/cpus.c +++ b/cpus.c @@ -520,11 +520,18 @@ void configure_icount(QemuOpts *opts, Error **errp) } return; } + + icount_sleep = qemu_opt_get_bool(opts, "sleep", true); if (icount_sleep) { icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, icount_warp_rt, NULL); } + icount_align_option = qemu_opt_get_bool(opts, "align", false); + + if (icount_align_option && !icount_sleep) { + error_setg(errp, "align=on and sleep=no are incompatible"); + } if (strcmp(option, "auto") != 0) { errno = 0; icount_time_shift = strtol(option, &rem_str, 0); @@ -535,6 +542,8 @@ void configure_icount(QemuOpts *opts, Error **errp) return; } else if (icount_align_option) { error_setg(errp, "shift=auto and align=on are incompatible"); + } else if (!icount_sleep) { + error_setg(errp, "shift=auto and sleep=no are incompatible"); } use_icount = 2; diff --git a/qemu-options.hx b/qemu-options.hx index ec356f6..c245714 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3086,9 +3086,10 @@ re-inject them. ETEXI DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ - "-icount [shift=N|auto][,align=on|off]\n" \ + "-icount [shift=N|auto][,align=on|off][,sleep=no]\n" \ " enable virtual instruction counter with 2^N clock ticks per\n" \ - " instruction and enable aligning the host and virtual clocks\n", QEMU_ARCH_ALL) + " instruction, enable aligning the host and virtual clocks\n" \ + " or disable real time cpu sleeping\n", QEMU_ARCH_ALL) STEXI @item -icount [shift=@var{N}|auto] @findex -icount @@ -3097,6 +3098,13 @@ instruction every 2^@var{N} ns of virtual time. If @code{auto} is specified then the virtual cpu speed will be automatically adjusted to keep virtual time within a few seconds of real time. +When the virtual cpu is sleeping, the virtual time will advance at default +speed unless @option{sleep=no} is specified. +With @option{sleep=no}, the virtual time will jump to the next timer deadline +instantly whenever the virtual cpu goes to sleep mode and will not advance +if no timer is enabled. This behavior give deterministic execution times from +the guest point of view. + Note that while this option can give deterministic behavior, it does not provide cycle accurate emulation. Modern CPUs contain superscalar out of order cores with complex cache hierarchies. The number of instructions diff --git a/vl.c b/vl.c index 15bccc4..79e2e07 100644 --- a/vl.c +++ b/vl.c @@ -470,6 +470,9 @@ static QemuOptsList qemu_icount_opts = { }, { .name = "align", .type = QEMU_OPT_BOOL, + }, { + .name = "sleep", + .type = QEMU_OPT_BOOL, }, { /* end of list */ } },