Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1239328imm; Fri, 15 Jun 2018 13:34:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKN5EItAnfqwPsE4j2V0N1iUdHY7TQyNiUTq4XTCoUYZUIJcajDt03EcH1uUV8uaxrIkAKb X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr3644258plo.281.1529094882572; Fri, 15 Jun 2018 13:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529094882; cv=none; d=google.com; s=arc-20160816; b=rQCs2ybaiyr6j+hskBMUSohe3msPQYRjuST6kN5PPcT4NWY2XtVejmfKhEN5GqcmQ+ VesQoSGTiQ6XueKe7hC0XTxo9JHNoOOaywTYmYhZDZRzriRYSZ2uIeaXELrvM8/A0wrU Qj4dIxReCJxfkV+0WhsLtOEYTl2LnVD3DVsRLKkDJbdrNq0ohgKMdxwR1K07fy+ixyJ9 7eAx4xbx669TyeJSIeND7OiVUofJHsfYD42c82WS8etqk2A3KrXbN7F3IeWNVkZys6CP 2gMHysUaUEPE6Yb7/4XXFOu2Jf6N8wI2deYEVwvMC/waushNiuSLpN1zIOlMRhctyq6X R6Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=zncqFjI/hKTGTkg4BRSpjSqqTxRK/OiPBZ2XYrcYUmw=; b=OMZRo1WgijNOySvmolSIkod4GYeoGHFhjm/tZWM7QI8fDPlBjvR1tJTZ22tPS/+CZp GYU9mRMBJLXfVh49QbGF8mJkeUKndDhvHQefU21taqa96rOnrMPijPTCg5DUtTX3OFf2 CNaBL3zX4QDhhH1PHQSlz07MujW4ttJwZ0Bv7fkSi2Mg8QYq6wK9vxgKtNpb6RzO7a1M x5ZFood7nWZqUjg+1mHWK9Fl8IQXTNTOf16QWvRrgGfoHjIw2hnYlrLCXcKRWM++KLKG p4ZzWeUPc8K+CpUBK/4tAT5eBPHSrjYo/SCmg+CS7Ym242mO8iZ3eGKItO67Hy45vJjW T9jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=YcaMk5gw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si8505502plt.149.2018.06.15.13.34.27; Fri, 15 Jun 2018 13:34:42 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=YcaMk5gw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966436AbeFOUeD (ORCPT + 99 others); Fri, 15 Jun 2018 16:34:03 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:52143 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966118AbeFOUeC (ORCPT ); Fri, 15 Jun 2018 16:34:02 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 41eb9e91 for ; Fri, 15 Jun 2018 20:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=dhzbR9Rzbz95OZkTVQ4Hb9LZ7k4=; b=YcaMk5 gwbajH67+sLPbqxivjlWE7/bek+M4i3Bdk2osEz7V/n/9fPUvFZWoyr3gWkeT3co hLi2d69WKd229WxyrOGb2xhEGp6oUn4rNfGI1kZvE3iGQzOl1fOVoMgDHP2ttLf9 QbQRwilpDvNhk3vngti29jtfHa1J80+2lCrFa82U0LASJUGKV8E+gysLlccoOeMv jskaOGsOlZKvvHu8eB+FKIB5LN0nccG5HYatqXeLsIb/WqobdKdDja8aKbL66ogB gpXJNKcOCVE5zmjdaSwjT/3OqwGMf4oQghSdF5ZrwNDAaCWonAklPC1dCkFXa31f /oVvA2orJ2wYqK4g== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ca293eb6 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Fri, 15 Jun 2018 20:28:36 +0000 (UTC) Received: by mail-ot0-f182.google.com with SMTP id a5-v6so12359503otf.12 for ; Fri, 15 Jun 2018 13:34:00 -0700 (PDT) X-Gm-Message-State: APt69E3QNvS/5tGtdFuXvzChIZYQEGA7d3Aiw2GQ80XDhWmVxeZ+1CB9 65k5i5lvf4ZgcObFRjORmiRXwK1zUHGpSHrJ9C0= X-Received: by 2002:a9d:59ed:: with SMTP id u45-v6mr2086541otg.320.1529094839684; Fri, 15 Jun 2018 13:33:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Jason A. Donenfeld" Date: Fri, 15 Jun 2018 22:33:47 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Lazy FPU restoration / moving kernel_fpu_end() to context switch To: Andrew Lutomirski Cc: riel@surriel.com, dave.hansen@linux.intel.com, LKML , X86 ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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.