Received: by 10.223.185.116 with SMTP id b49csp8546576wrg; Fri, 2 Mar 2018 03:53:32 -0800 (PST) X-Google-Smtp-Source: AG47ELvhR+t5yQvFSPiR9P3Q0t4CxdD6gxB79g90Kk15OkXX3ymG47D3PtW8LvUymQYULUjVoY7i X-Received: by 2002:a17:902:3283:: with SMTP id z3-v6mr5209045plb.118.1519991612765; Fri, 02 Mar 2018 03:53:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519991612; cv=none; d=google.com; s=arc-20160816; b=J4NeTL7Z+Ny1sVBDdglyDlooNVraEURcIIwcjqattJzoofgwOJUTS1IwKWIcqrUSKt u84gRkVHknvi26uyBW6fdi5ebyBZhoQK7TVsp5OjSqnQ7LRXUb6hmwg/vksVzaI1NIWr kkq4TwReaHrG3S1A7bTEgzuuAzfBHd2mItJ2nRtWg8yTiVdZh1Qhkt5gFx8SgxZne9Qv xbFaF53jZ3zpyt40iMLeZyYtkgkg6bfTiRsf53jhwic0ajKbkqDrMNRGo9X8kXBd1i4g 7lHoMFMYSfIlXiR4116/Ip711RYP0TI8LhzZFxlbgaig6TLpgau3Y05rxxwUerajAlPL veOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=s4W1FxZrRzOWtjKkq0SuJh1OfsrWEHzBdmIP2fU2o6Q=; b=GZjcUxEggs5MZgu2djtZckGMgI2PW/PEN3l5QUlzhfUNXsXMf4vMLuuiUPKcUQfrOF GhvM1ldMo0wEmVvRKTM2pQqXcDID5MmvjCsVOqEDyAwDKAirNt5zIYG9d3uZfMavueYn vwej4/nd3f+Pa38WmVSmRjIEw0bN0AHtLsXMTK87tXSM5/8yKwJlSvd7LzMi+IqlFiVc ctasC5HUdU0zIRLL5oXVbHVXRqWDtp/klB5tMF6VS2hoSoeGN5qO2QORTdegPCcG0t01 TqG6i9pibNwgnN0MzIkhBU4wadUv44rbyx4qgZLtj9IonSv9hxSPvc3SlWoaB5YphxfK UPnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si3893444pgc.273.2018.03.02.03.53.17; Fri, 02 Mar 2018 03:53:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936280AbeCBLwb (ORCPT + 99 others); Fri, 2 Mar 2018 06:52:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934748AbeCBLw1 (ORCPT ); Fri, 2 Mar 2018 06:52:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFD6517CEF6; Fri, 2 Mar 2018 11:52:26 +0000 (UTC) Received: from [10.36.116.70] (ovpn-116-70.ams2.redhat.com [10.36.116.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 764DB10B0F20; Fri, 2 Mar 2018 11:52:25 +0000 (UTC) Subject: Re: [PATCH] KVM: PPC: Book3S HV: Fix guest time accounting with VIRT_CPU_ACCOUNTING_GEN To: Laurent Vivier , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, Paul Mackerras , David Gibson References: <20180302105156.19506-1-lvivier@redhat.com> From: Paolo Bonzini Message-ID: Date: Fri, 2 Mar 2018 12:52:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180302105156.19506-1-lvivier@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 02 Mar 2018 11:52:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 02 Mar 2018 11:52:26 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2018 11:51, Laurent Vivier wrote: > Since commit 8b24e69fc47e ("KVM: PPC: Book3S HV: Close race with testing > for signals on guest entry"), if CONFIG_VIRT_CPU_ACCOUNTING_GEN is set, the > guest time is not accounted to guest time and user time, but instead to > system time. > > This is because guest_enter()/guest_exit() are called while interrupts > are disabled and the tick counter cannot be updated between them. > > To fix that, move guest_exit() after local_irq_enable(), and as > guest_enter() is called with IRQ disabled, calls guest_enter_irqoff() > instead. > > Fixes: 8b24e69fc47e > ("KVM: PPC: Book3S HV: Close race with testing for signals on guest entry") > Signed-off-by: Laurent Vivier Reviewed-by: Paolo Bonzini > --- > arch/powerpc/kvm/book3s_hv.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 89707354c2ef..8274c2807202 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -2885,7 +2885,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) > */ > trace_hardirqs_on(); > > - guest_enter(); > + guest_enter_irqoff(); > > srcu_idx = srcu_read_lock(&vc->kvm->srcu); > > @@ -2893,8 +2893,6 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) > > srcu_read_unlock(&vc->kvm->srcu, srcu_idx); > > - guest_exit(); > - > trace_hardirqs_off(); > set_irq_happened(trap); > > @@ -2937,6 +2935,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) > kvmppc_set_host_core(pcpu); > > local_irq_enable(); > + guest_exit(); > > /* Let secondaries go back to the offline loop */ > for (i = 0; i < controlled_threads; ++i) { >