From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 5/9] KVM: VMX: clamp PLE window Date: Wed, 20 Aug 2014 09:18:06 +0200 Message-ID: <53F44BAE.9040405@redhat.com> References: <1408480536-8240-1-git-send-email-rkrcmar@redhat.com> <1408480536-8240-6-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, Gleb Natapov , Raghavendra KT , Vinod Chegu , Hui-Zhi To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Return-path: Received: from mail-we0-f172.google.com ([74.125.82.172]:37597 "EHLO mail-we0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809AbaHTHSL (ORCPT ); Wed, 20 Aug 2014 03:18:11 -0400 In-Reply-To: <1408480536-8240-6-git-send-email-rkrcmar@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 19/08/2014 22:35, Radim Kr=C4=8Dm=C3=A1=C5=99 ha scritto: > Modifications could get unwanted values of PLE window. (low or negati= ve) > Use ple_window and the maximal value that cannot overflow as bounds. >=20 > ple_window_max defaults to a very high value, but it would make sense= to > set it to some fraction of the scheduler tick. >=20 > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > arch/x86/kvm/vmx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 66259fd..e1192fb 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -144,6 +144,10 @@ module_param(ple_window_grow, int, S_IRUGO); > static int ple_window_shrink =3D KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK; > module_param(ple_window_shrink, int, S_IRUGO); > =20 > +/* Default is to compute the maximum so we can never overflow. */ > +static int ple_window_max =3D INT_MAX / KVM_VMX_DEFAULT_PLE_WINDOW_G= ROW; > +module_param(ple_window_max, int, S_IRUGO); > + > extern const ulong vmx_return; > =20 > #define NR_AUTOLOAD_MSRS 8 > @@ -5704,7 +5708,7 @@ static void grow_ple_window(struct kvm_vcpu *vc= pu) > else > new =3D old + ple_window_grow; > =20 > - vmx->ple_window =3D new; > + vmx->ple_window =3D min(new, ple_window_max); > } Please introduce a dynamic overflow-avoiding ple_window_max (like what you have in patch 9) already in patch 4... > static void shrink_ple_window(struct kvm_vcpu *vcpu) > @@ -5720,7 +5724,7 @@ static void shrink_ple_window(struct kvm_vcpu *= vcpu) > else > new =3D old - ple_window_shrink; > =20 > - vmx->ple_window =3D new; > + vmx->ple_window =3D max(new, ple_window); =2E.. and also squash this in patch 4. This patch can then introduce the ple_window_max module parameter (usin= g module_param_cb to avoid overflows). Paolo > } > =20 > /* >=20