Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp928499imm; Wed, 11 Jul 2018 13:38:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfE1aUll2n8sCQBolxwT7wNR2np3Zwh0/+2jflqQ6iCj+CF/KVf6C/snakDlXIMhqqUK0BM X-Received: by 2002:a63:571d:: with SMTP id l29-v6mr140168pgb.296.1531341507576; Wed, 11 Jul 2018 13:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531341507; cv=none; d=google.com; s=arc-20160816; b=WmWPfkgydYrT3582r6EOyhedhxfHjHJ4ZB/N+nD3Z7x/fc7KQW/tFLY/mexddLDFXo Lb5xcfE/0ztazkMnB1sF9t6GIMJZK79KFT3deQhqVo0Om/AxIWIBwqF2p/ddo/MNicg7 NscmKYSdkQaZPOV/UqSBqYRwneGCvNyPF5MOPUsdDCVYQA3GCnZ1s4pgFvBOsZ1KGfIQ HWCiIxFp8jorOJ3L3fC0hSSLyEhk+n+onAN26532A6RGBxGzVWP9nhU8tTS0I+oW1bEM QTiewDoOSg9of1yFytvNvCxDYhAncy3Rl95kJmm0VFiSFBPx8pAK0jmaU7noBnnTxjoP +FCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id:arc-authentication-results; bh=eiRqfMfnBjnfTAP1LrpP6PgdxXlrcZ2mj1zhK0aBwok=; b=FVNNBkdunxRx0bU27Uv5UZhuM5Sj6C9Us7phvzac3Okc5G39aPE383Rme8Bhx4ppog i7weKz4ysi6UvIcZj7qunyx+VCiibNFuRDOvUWuOuuC6FWOrrCmPg5rl6mbMClLdUTIf z7nDC0VJdPTR6SkqecFvElZ39Zzhu/bYpfwTNUKXFLt3/hTkRL1wxMT9oq3hPNWr53mh 6rh1FXpo4eQw3tMkQrjvhZP3a6T5ex5vOs/guOtG4uja4x6Fv62+cW4R3ED/abUURvu8 tfhqvI0iQrglcVWRUT6V03W/Pk7b6My3qR3XSR3N22dQmP+vy+X9liLhRAkSCjc2/NXU iMkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5-v6si11380922pgn.95.2018.07.11.13.38.11; Wed, 11 Jul 2018 13:38:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389838AbeGKUQi (ORCPT + 99 others); Wed, 11 Jul 2018 16:16:38 -0400 Received: from shelob.surriel.com ([96.67.55.147]:54170 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388887AbeGKUQh (ORCPT ); Wed, 11 Jul 2018 16:16:37 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fdLRa-0004xv-6j; Wed, 11 Jul 2018 16:10:34 -0400 Message-ID: <1531339833.26425.1.camel@surriel.com> Subject: Re: Lazy FPU restoration / moving kernel_fpu_end() to context switch From: Rik van Riel To: Sebastian Andrzej Siewior , "Jason A. Donenfeld" Cc: Andrew Lutomirski , dave.hansen@linux.intel.com, LKML , X86 ML Date: Wed, 11 Jul 2018 16:10:33 -0400 In-Reply-To: <20180711162850.52jmzsuwegpk7rag@breakpoint.cc> References: <20180711162850.52jmzsuwegpk7rag@breakpoint.cc> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-PBWDaPbCpr3to4z8rhDe" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-PBWDaPbCpr3to4z8rhDe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2018-07-11 at 18:28 +0200, Sebastian Andrzej Siewior wrote: > On 2018-06-15 22:33:47 [+0200], Jason A. Donenfeld wrote: > > On Fri, Jun 15, 2018 at 8:32 PM Andy Lutomirski > > wrote: > > > quite in the form you imagined. The idea that we've tossed > > > around is > > > to restore FPU state on return to user mode. Roughly, we'd > > > introduce > > > a new thread flag TIF_FPU_UNLOADED (name TBD). > > > prepare_exit_to_usermode() would notice this flag, copy the > > > fpstate to > > > fpregs, and clear the flag. (Or maybe exit_to_usermode_loop() -- > > > No > > > one has quite thought it through, but I think it should be > > > outside the > > > loop.) We'd update all the FPU accessors to understand the flag. > >=20 > > Yes! This is exactly what I was thinking. Then those calls to > > begin() > > and end() could be placed as close to the actual FPU usage as > > possible. >=20 > I was thinking about this myself. Did anyone try to hack something in > the meantime? I might want to look into this, too :) I have implemented this before, back before the big rewrite of the syscall entry and exit code. It seemed to work fine. --=20 All Rights Reversed. --=-PBWDaPbCpr3to4z8rhDe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAltGZDkACgkQznnekoTE 3oNjyQgAwGynix8qb8Oi/WeLSl9f9nUgh2s2mqE2a56rq6xBoRopdm/zYttDypQI CggihoFE+M2gFjfarlSFGaJiKv/VwASvLcVjd5olmBTJ/qgC6Nt1icNAOKkAJMe8 VTl/wcN9M2J86dx7NJPDBLg77oEzL15erc5wOQ4mihxE/bg4lI8sjjo8EWYOv3BY 4VUdSnHGm8XMKZuHj96mltdowedGkTfL0Md2Tns56XsCLxqW4ec1dGJggb55qvnr IqaBjWNEGZi80nK4HP6YVcoUL6dDcjqfhlQOfRp2luK6vHb4a7YBEdujK9O4JtaV 7AGvolsr9NfhK+kAxT+7Z9EG9YmaAQ== =pYzj -----END PGP SIGNATURE----- --=-PBWDaPbCpr3to4z8rhDe--