From patchwork Fri Oct 14 05:19:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 119701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6EB9B6F95 for ; Fri, 14 Oct 2011 16:19:54 +1100 (EST) Received: from localhost ([::1]:58289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REaBK-0000U5-47 for incoming@patchwork.ozlabs.org; Fri, 14 Oct 2011 01:19:42 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REaBE-0000Tt-MY for qemu-devel@nongnu.org; Fri, 14 Oct 2011 01:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REaBC-0004jR-Po for qemu-devel@nongnu.org; Fri, 14 Oct 2011 01:19:36 -0400 Received: from ozlabs.org ([203.10.76.45]:41373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REaBC-0004iq-47; Fri, 14 Oct 2011 01:19:34 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id CF66DB6F95; Fri, 14 Oct 2011 16:19:23 +1100 (EST) From: David Gibson To: agraf@suse.de Date: Fri, 14 Oct 2011 16:19:08 +1100 Message-Id: <1318569548-8537-1-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.6.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] ppcr: Avoid decrementer related kvm exits 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 In __cpu_ppc_store_decr(), we set up a regular timer used to trigger decrementer interrupts. This is necessary to implement the decrementer properly under TCG, but is unnecessary under KVM (true for both Book3S-PR and Book3S-HV KVM variants), because the kernel handles generating and delivering decrementer exceptions. Under kvm, in fact, the timer causes expensive and unnecessary exits from kvm to qemu. This patch, therefore, disables setting the timer when kvm is in use. Signed-off-by: Anton Blanchard Signed-off-by: David Gibson --- hw/ppc.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/ppc.c b/hw/ppc.c index 25b59dd..87aa4e5 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -658,21 +658,24 @@ static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp, int is_excp) { ppc_tb_t *tb_env = env->tb_env; - uint64_t now, next; LOG_TB("%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__, decr, value); - now = qemu_get_clock_ns(vm_clock); - next = now + muldiv64(value, get_ticks_per_sec(), tb_env->decr_freq); - if (is_excp) { - next += *nextp - now; - } - if (next == now) { - next++; + if (!kvm_enabled()) { + uint64_t now, next; + + now = qemu_get_clock_ns(vm_clock); + next = now + muldiv64(value, get_ticks_per_sec(), tb_env->decr_freq); + if (is_excp) { + next += *nextp - now; + } + if (next == now) { + next++; + } + *nextp = next; + /* Adjust timer */ + qemu_mod_timer(timer, next); } - *nextp = next; - /* Adjust timer */ - qemu_mod_timer(timer, next); /* If we set a negative value and the decrementer was positive, raise an * exception.