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 18:26:54 +0200 Message-ID: <20140820162653.GC20453@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> <20140820124112.GC28873@potion.brq.redhat.com> <53F49F80.1090408@redhat.com> <20140820153115.GA20453@potion.brq.redhat.com> <53F4BFF3.3060606@redhat.com> <20140820160137.GB20453@potion.brq.redhat.com> <53F4C6D2.9050209@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: <53F4C6D2.9050209@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2014-08-20 18:03+0200, Paolo Bonzini: > Il 20/08/2014 18:01, Radim Kr=C4=8Dm=C3=A1=C5=99 ha scritto: > > 2014-08-20 17:34+0200, Paolo Bonzini: > >> Il 20/08/2014 17:31, Radim Kr=C4=8Dm=C3=A1=C5=99 ha scritto: > >>> Btw. without extra code, we are still going to overflow on races = when > >>> changing PW_grow, should they be covered as well? > >> > >> You mean because there is no spinlock or similar protecting the ch= anges? > >> I guess you could use a seqlock. > >=20 > > Yes, for example between a modification of ple_window > > new =3D min(old, PW_actual_max) * PW_grow > > which gets compiled into something like this: > > 1) tmp =3D min(old, PW_actual_max) > > 2) new =3D tmp * PW_grow > > and a write to increase PW_grow > > 3) PW_actual_max =3D min(PW_max / new_PW_grow, PW_actual_max) > > 4) PW_grow =3D new_PW_grow > > 5) PW_actual_max =3D PW_max / new_PW_grow > >=20 > > 3 and 4 can exectute between 1 and 2, which could overflow. > >=20 > > I don't think they are important enough to warrant a significant > > performance hit of locking. >=20 > A seqlock just costs two memory accesses to the same (shared) cache l= ine > as the PW data, and a non-taken branch. Oh, seqlock readers do not have to write to shared memory, so it is acceptable ... > I don't like code that is > unsafe by design... I wouldn't say it is unsafe, because VCPU's PW is always greater than module's PW. We are just going to PLE exit sooner than expected.