Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933113AbcLNVhV (ORCPT ); Wed, 14 Dec 2016 16:37:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55986 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbcLNVhT (ORCPT ); Wed, 14 Dec 2016 16:37:19 -0500 Date: Wed, 14 Dec 2016 22:36:29 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Denis Plotnikov Cc: rkagan@virtuozzo.com, den@virtuozzo.com, pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] KVM: x86: avoid redundant REQ_EVENT Message-ID: <20161214213628.GB6667@potion> References: <20161214105908.322638-1-dplotnikov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161214105908.322638-1-dplotnikov@virtuozzo.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Dec 2016 21:36:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1427 Lines: 34 2016-12-14 13:59+0300, Denis Plotnikov: > When processing KVM_REQ_EVENT, apic_update_ppr is called which may set > KVM_REQ_EVENT again if the recalculated value of PPR becomes smaller > than the previous one. This results in cancelling the guest entry and > reiterating in vcpu_enter_guest. > > However this is unnecessary because at this point KVM_REQ_EVENT is > already being processed and there are no other changes in the lapic > that may require full-fledged state recalculation. > > This situation is often hit on systems with TPR shadow, where the > TPR can be updated by the guest without a vmexit, so that the first > apic_update_ppr to notice it is exactly the one called while > processing KVM_REQ_EVENT. > > To avoid it, introduce a parameter in apic_update_ppr allowing to > suppress setting of KVM_REQ_EVENT, and use it on the paths called from > KVM_REQ_EVENT processing. > Also add the parameter to kvm_cpu_get_interrupt to be passed through > to apic_update_ppr to make sure the supression of KVM_REQ_EVENT is done > in the KVM_REQ_EVENT processing path only. > > This microoptimization gives 10% performance increase on a synthetic > test doing a lot of IPC in Windows using window messages. > > Reviewed-by: Roman Kagan > Signed-off-by: Denis Plotnikov > --- It is not pretty, but desirable, Reviewed-by: Radim Krčmář Thanks.