From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 9/9] KVM: VMX: automatic PLE window maximum Date: Wed, 20 Aug 2014 14:41:12 +0200 Message-ID: <20140820124112.GC28873@potion.brq.redhat.com> References: <1408480536-8240-1-git-send-email-rkrcmar@redhat.com> <1408480536-8240-10-git-send-email-rkrcmar@redhat.com> <53F44B40.6060806@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Gleb Natapov , Raghavendra KT , Vinod Chegu , Hui-Zhi To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <53F44B40.6060806@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2014-08-20 09:16+0200, Paolo Bonzini: > Il 19/08/2014 22:35, Radim Kr=C4=8Dm=C3=A1=C5=99 ha scritto: > > Every increase of ple_window_grow creates potential overflows. > > They are not serious, because we clamp ple_window and userspace is > > expected to fix ple_window_max within a second. > > --- > I think avoiding overflows is better. In fact, I think you should ca= ll > this function for ple_window_max too. (Ack, I just wanted to avoid the worst userspace error, which is why PW_max hasn't changed when PW_grow got smaller and we could overflow.) > You could keep the ple_window_max variable to the user-set value. > Whenever ple_window_grow or ple_window_max are changed, you can set a= n > internal variable (let's call it ple_window_actual_max, but I'm not w= ed > to this name) to the computed value, and then do: >=20 > if (ple_window_grow < 1 || ple_window_actual_max < ple_window) > new =3D ple_window; > else if (ple_window_grow < ple_window) > new =3D max(ple_window_actual_max, old) * ple_window_grow; > else > new =3D max(ple_window_actual_max, old) + ple_window_grow; Oh, I like that this can get rid of all overflows, ple_window_actual_ma= x (PW_effective_max?) is going to be set to "ple_window_max [/-] ple_window_grow" in v2. > (I think the || in the first "if" can be eliminated with some creativ= ity > in clamp_ple_window_max). To do it, we'll want to intercept changes to ple_window as well. (I disliked this patch a lot even before :)