From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B364AC3A589 for ; Sun, 18 Aug 2019 17:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AA0E20B7C for ; Sun, 18 Aug 2019 17:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566150821; bh=Zo78VJybw19gN21uSvfyVKmuea3MQ5HQD79PxNvUM0w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=qf4rDPci+27Iqoa+o+mb6iBkBXGjbggDikw9ZJllRKmgHfTiTD+oGijnZqJFhIby2 /sJlLbYWpQ+Xlv8VAhxwnMh1XEN9wDXOH7WRTz8T+atBWYAsNcLv2LLegS0F1LG+ly Q70x/kKeAt3ly9hvGltc8qBiJ/ZBTQVSKiwq9jsI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbfHRRxj (ORCPT ); Sun, 18 Aug 2019 13:53:39 -0400 Received: from inca-roads.misterjones.org ([213.251.177.50]:58464 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfHRRxj (ORCPT ); Sun, 18 Aug 2019 13:53:39 -0400 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:AES256-GCM-SHA384:256) (Exim 4.80) (envelope-from ) id 1hzPMv-0007XI-97; Sun, 18 Aug 2019 19:53:29 +0200 Date: Sun, 18 Aug 2019 18:53:26 +0100 From: Marc Zyngier To: Paolo Bonzini Cc: Radim =?UTF-8?B?S3LEjW3DocWZ?= , Julien Thierry , Suzuki K Poulose , James Morse , Joerg Roedel , Suravee Suthikulpanit , Tangnianyao , , Subject: Re: [PATCH 2/2] KVM: Call kvm_arch_vcpu_blocking early into the blocking sequence Message-ID: <20190818185326.63f3ea9d@why> In-Reply-To: References: <20190802103709.70148-1-maz@kernel.org> <20190802103709.70148-3-maz@kernel.org> Organization: Approximate X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: pbonzini@redhat.com, rkrcmar@redhat.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, james.morse@arm.com, joro@8bytes.org, Suravee.Suthikulpanit@amd.com, tangnianyao@huawei.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 2 Aug 2019 12:46:33 +0200 Paolo Bonzini wrote: > On 02/08/19 12:37, Marc Zyngier wrote: > > When a vpcu is about to block by calling kvm_vcpu_block, we call > > back into the arch code to allow any form of synchronization that > > may be required at this point (SVN stops the AVIC, ARM synchronises > > the VMCR and enables GICv4 doorbells). But this synchronization > > comes in quite late, as we've potentially waited for halt_poll_ns > > to expire. > > > > Instead, let's move kvm_arch_vcpu_blocking() to the beginning of > > kvm_vcpu_block(), which on ARM has several benefits: > > > > - VMCR gets synchronised early, meaning that any interrupt delivered > > during the polling window will be evaluated with the correct guest > > PMR > > - GICv4 doorbells are enabled, which means that any guest interrupt > > directly injected during that window will be immediately recognised > > > > Tang Nianyao ran some tests on a GICv4 machine to evaluate such > > change, and reported up to a 10% improvement for netperf: > > > > > > netperf result: > > D06 as server, intel 8180 server as client > > with change: > > package 512 bytes - 5500 Mbits/s > > package 64 bytes - 760 Mbits/s > > without change: > > package 512 bytes - 5000 Mbits/s > > package 64 bytes - 710 Mbits/s > > > > > > Signed-off-by: Marc Zyngier > > --- > > virt/kvm/kvm_main.c | 7 +++---- > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index 887f3b0c2b60..90d429c703cb 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -2322,6 +2322,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > > bool waited = false; > > u64 block_ns; > > > > + kvm_arch_vcpu_blocking(vcpu); > > + > > start = cur = ktime_get(); > > if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) { > > ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); > > @@ -2342,8 +2344,6 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > > } while (single_task_running() && ktime_before(cur, stop)); > > } > > > > - kvm_arch_vcpu_blocking(vcpu); > > - > > for (;;) { > > prepare_to_swait_exclusive(&vcpu->wq, &wait, TASK_INTERRUPTIBLE); > > > > @@ -2356,9 +2356,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > > > > finish_swait(&vcpu->wq, &wait); > > cur = ktime_get(); > > - > > - kvm_arch_vcpu_unblocking(vcpu); > > out: > > + kvm_arch_vcpu_unblocking(vcpu); > > block_ns = ktime_to_ns(cur) - ktime_to_ns(start); > > > > if (!vcpu_valid_wakeup(vcpu)) > > > > Acked-by: Paolo Bonzini Thanks for that. I've pushed this patch into -next so that it gets a bit of exposure (I haven't heard from the AMD folks, and I'd like to make sure it doesn't regress their platforms). M. -- Without deviation from the norm, progress is not possible.