Received: by 10.213.65.68 with SMTP id h4csp850174imn; Tue, 20 Mar 2018 17:41:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELvKha72YvQCZ97A2UdWseFqV3+1xmMnAnpJ6UpAAcKl+kqMTl3psCDPJ5im59B3Oq3kAKV1 X-Received: by 2002:a17:902:52e6:: with SMTP id a93-v6mr14106310pli.10.1521592904046; Tue, 20 Mar 2018 17:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521592903; cv=none; d=google.com; s=arc-20160816; b=hEzvUAyD7W1WXLe+PlEgZyJVoN+AgqEZSyhMf2xLVsDyykQbR157m18Fq2CK/VPm4L 0L2JQ+hY1VNDYgGg40yyum9AvmJEIblkHLh7VHVksdhNZrItfmnr4d0AaHX2s9ZQ84MQ MjH+cAg91yUdifV/1yjluepOnHgA7Wm3s0i3E/jho5+7VelX0R+EPhd7n0D7AH5y2HT+ 1Ap5NvJZFCaU+yBajSCV1JFVImbUWTpDnYFIyOxBnU/Xie7ltwKobnFUNTCTanCoJxE9 mCxvvpnXPoj0U0kJksX3n+zEyIgUTAaVIV7Gy8RCqY8PsG0M9nVIa3Yqaoi54mXwZXbS mOhg== 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 :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=d5REJRa5NlDKv5HD2KZK6D0/TTENt/88GC1Il+hSd5I=; b=Ugn0cLCigwVBh6+RnPHXs/pphUUEo1o47T5zS/E6xQHM+tbB8QQQ/tE+LKis+MSAz7 zJL+b5YJiCMAVozuz38ZS45++dmfPK4zbG0xZ+gNVLR1WJAxSRWS0b/jW0fu4dtm6gTs sR7C26cqdtaJmb0XosDvh9YmUNV5+GML/2+/RXfFdrqr4QRghGPRZYeGyYc5z+S3fwk0 qL/6hjvCi1y2PLdE11FpFWQeGU6y9ZOqFlVB1l3TacGAMvnigwKVcVcZvA0wglZD5OUb 7d/AM/T4Ic7zBSv/NVholc97U6wnIhfFwSjwDxdryeON9LRjG4AP8oiK8PFdIVhDHF0t LFvQ== 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 v21si1926949pgc.569.2018.03.20.17.41.29; Tue, 20 Mar 2018 17:41:43 -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 S1751615AbeCUAkT (ORCPT + 99 others); Tue, 20 Mar 2018 20:40:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:57096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbeCUAkP (ORCPT ); Tue, 20 Mar 2018 20:40:15 -0400 Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 099C52183B for ; Wed, 21 Mar 2018 00:40:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 099C52183B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org Received: by mail-io0-f177.google.com with SMTP id m83so4581029ioi.8 for ; Tue, 20 Mar 2018 17:40:14 -0700 (PDT) X-Gm-Message-State: AElRT7GH85NXK+reuSmwdgR69Ptt2PJie5xfgojfs/k65PSRlyN3UHRU K1/Xh0bFTgt5KHlPomZ8GYK01Bp/UiNjmwGqUb1l0A== X-Received: by 10.107.40.73 with SMTP id o70mr18237405ioo.6.1521592814297; Tue, 20 Mar 2018 17:40:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.137.70 with HTTP; Tue, 20 Mar 2018 17:39:53 -0700 (PDT) In-Reply-To: References: <7f0ddb3678814c7bab180714437795e0@AcuMS.aculab.com> <7f8d811e79284a78a763f4852984eb3f@AcuMS.aculab.com> <20180320082651.jmxvvii2xvmpyr2s@gmail.com> From: Andy Lutomirski Date: Wed, 21 Mar 2018 00:39:53 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/3] kernel: add support for 256-bit IO access To: David Laight Cc: Andy Lutomirski , Ingo Molnar , Thomas Gleixner , Rahul Lakkireddy , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "mingo@redhat.com" , "hpa@zytor.com" , "davem@davemloft.net" , "akpm@linux-foundation.org" , "torvalds@linux-foundation.org" , "ganeshgr@chelsio.com" , "nirranjan@chelsio.com" , "indranil@chelsio.com" , Peter Zijlstra , Fenghua Yu , Eric Biggers , Rik van Riel 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 Tue, Mar 20, 2018 at 3:10 PM, David Laight wrote: > From: Andy Lutomirski >> Sent: 20 March 2018 14:57 > ... >> I'd rather see us finally finish the work that Rik started to rework >> this differently. I'd like kernel_fpu_begin() to look like: >> >> if (test_thread_flag(TIF_NEED_FPU_RESTORE)) { >> return; // we're already okay. maybe we need to check >> in_interrupt() or something, though? >> } else { >> XSAVES/XSAVEOPT/XSAVE; >> set_thread_flag(TIF_NEED_FPU_RESTORE): >> } >> >> and kernel_fpu_end() does nothing at all. > > I guess it might need to set (clear?) the CFLAGS bit for a process > that isn't using the fpu at all - which seems a sensible feature. What do you mean "CFLAGS"? But we no longer have any concept of "isn't using the fpu at all" -- we got rid of that. > >> We take the full performance hit for a *single* kernel_fpu_begin() on >> an otherwise short syscall or interrupt, but there's no additional >> cost for more of them or for long-enough-running things that we >> schedule in the middle. > > It might be worth adding a parameter to kernel_fpu_begin() to indicate > which registers are needed, and a return value to say what has been > granted. > Then a driver could request AVX2 (for example) and use a fallback path > if the register set isn't available (for any reason). > A call from an ISR could always fail. Last time I benchmarked it, XSAVEC on none of the state wasn't a whole lot faster than XSAVEC for all of it. > >> As I remember, the main hangup was that this interacts a bit oddly >> with PKRU, but that's manageable. > > WTF PKRU ?? PKRU is uniquely demented. All the rest of the XSAVEC state only affects code that explicitly references that state. PKRU affects every single access to user pages, so we need PKRU to match the current task at all times in the kernel. This means that, if we start deferring XRSTORS until prepare_exit_to_usermode(), we need to start restoring PKRU using WRPKRU in __switch_to(). Of course, *that* interacts a bit oddly with XINUSE, but maybe we don't care. Phooey on you, Intel, for putting PKRU into xstate and not giving a fast instruction to control XINUSE.