Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbcJCUXC (ORCPT ); Mon, 3 Oct 2016 16:23:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42028 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388AbcJCUWz (ORCPT ); Mon, 3 Oct 2016 16:22:55 -0400 Message-ID: <1475526171.4622.9.camel@redhat.com> Subject: Re: [PATCH RFC 4/5] x86,fpu: lazily skip FPU restore when still loaded From: Rik van Riel To: Dave Hansen , linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, pbonzini@redhat.com, mingo@redhat.com, luto@kernel.org, hpa@zytor.com, bp@suse.de Date: Mon, 03 Oct 2016 16:22:51 -0400 In-Reply-To: <57F2B9E9.7030806@linux.intel.com> References: <1475353895-22175-1-git-send-email-riel@redhat.com> <1475353895-22175-5-git-send-email-riel@redhat.com> <57F2B9E9.7030806@linux.intel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-seNJk+RhPJMPoBKBFRFZ" Mime-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 03 Oct 2016 20:22:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2059 Lines: 62 --=-seNJk+RhPJMPoBKBFRFZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2016-10-03 at 13:04 -0700, Dave Hansen wrote: > On 10/01/2016 01:31 PM, riel@redhat.com wrote: > >=20 > > =C2=A0/* > > + * Check whether an FPU's register set is still loaded in the CPU. > > + */ > > +static inline bool fpu_lazy_skip_restore(struct fpu *fpu) > > +{ > > + bool still_loaded =3D (fpu->fpstate_active && > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fpu->last_cpu =3D=3D > > raw_smp_processor_id() && > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0__this_cpu_read(fpu_fpregs_owner_ctx) > > =3D=3D fpu); > > + > > + fpu->fpregs_active =3D still_loaded; > > + return still_loaded; > > +} > I wonder if we should call this something more along the lines of > fpregs_activate_fast(), which returns if it managed to do the > activation > fast or not.=C2=A0=C2=A0I _think_ that's more along the lines of what it = is > actually doing.=C2=A0=C2=A0The fact that it can be lazy is really an > implementation detail. >=20 > What are the preempt rules with this thing?=C2=A0=C2=A0This needs to be c= alled > in > preempt-disabled contexts, right? Indeed, all the FPU context switching code needs=C2=A0 to be called in preempt-disabled contexts. You do not want to get preempted halfway through saving or restoring floating point registers. --=20 All rights reversed --=-seNJk+RhPJMPoBKBFRFZ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJX8r4bAAoJEM553pKExN6DooUH/0/pL6asT/8qFt+RcH0PZtt5 GvMoLoMd8NkVbNJBqqcmW0Rg3HhlzdnAAvO9BdDffiFyANOdWjNJIxr/Jd2XTKdv cTRRK0brLJ6yEacWWr+avBvrAZ0QxGapZr47Bgve6NV/avyUgphvfNIrR5aWizE6 8NYvCS4vH9muejejZE7OPJa1ScXPYjwr/cKRXk/FJYEL6P8445YsgsU+xgF9Jl3T E9uSfq3LfrXMz1n/eomjfbjtqwAoiHGRtpH6u7Nk95U8CsQWIRG1QQxxHXvjdcDE sib/l3aNt51YYAJCicXuzxb88PlHgD8hxVxbfQm66xITX4HhJla9R5PTeLQ8/xQ= =ONSB -----END PGP SIGNATURE----- --=-seNJk+RhPJMPoBKBFRFZ--