Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1233187imm; Fri, 15 Jun 2018 13:28:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMd1OtttI1AaF8icc1LZSCKjR6FOBxRgzkDgL+0nlErei6dbPf37YIsjwYNVSyyp8bQERb X-Received: by 2002:a63:3c4b:: with SMTP id i11-v6mr2907667pgn.414.1529094516441; Fri, 15 Jun 2018 13:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529094516; cv=none; d=google.com; s=arc-20160816; b=S12vGQZ5SETK5WS9/ejj3hq2VF/WhOVUZ2yCDGe2igXIu63a6feIjahH27HIx0UrK5 w3u+noNQW/7vyHLMzEeU5I0DYjOWywcGl6CVMHqfHH76Ixb1YSsci0POcBmyJSZucfoG UqSxLET33PTptv8ZK4Q9aKFCNgKIGl6e9V6JupXulh5Ec4ZbWLxVA6kW/6Npr3hCQETG 3VmP1W6++6UZkwy9pbOBZxx7kevGs716IJzd+ABbbxIiqY+CFprkOJ460jtO2OmHQTiF XByj0CSwfVtHQuX001lW5Aev1BhM01Unpd1QOosxs6gQovFMmPnfX+sfG7kovDhEM3ZN O5iw== 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=EnsJthVOrJoBKEthaCdZhnS+IxN5jshFx4E8c/Q0CzE=; b=muqrz3mNpjXqolPphanb1QLEgvYw0N5rEXaYJTp2Qst+xx/TYnVF9vBy0GWtpr3erJ PnciaCtaTdwa70qnZEPNf4EIoZj4ecIUfQhv2I9v//i3AuA4yuMKh3LOwFSZlVd0eWIE 7bK6OI5yILJAqlaL5F1ttViD7DronLFTHHJ7yNXpC4ZOU+zaRcAzj6Q/SE7GpECqabKq W9kWhhmHgX+0P7p7boreAYIjKas+/ignqiU7q1huBqPaw6H7b0aewYjhXkIvroBtmTxa KlZ3lo6O4OQqM4UfA7t0Xa/WyU7bNNP+XionP6Ldez3jnDiNZpGnkud/h7EwnbrFON0+ h29g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=G7m4WKVO; 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 f3-v6si9033648plf.436.2018.06.15.13.28.21; Fri, 15 Jun 2018 13:28:36 -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=G7m4WKVO; 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 S966398AbeFOU1x (ORCPT + 99 others); Fri, 15 Jun 2018 16:27:53 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:53479 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966118AbeFOU1w (ORCPT ); Fri, 15 Jun 2018 16:27:52 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d2b5ddeb for ; Fri, 15 Jun 2018 20:22:27 +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=3HdTvnwkOWFnpG7DplVEo34Vb+I=; b=G7m4WK VOotj2NnZGhhKT1Bzfg/gwJVkWWR339WXf317IjeugZM8p4L/aJAVL3cdC6fiXV5 IQftCrkv8CuDlk5k9wwcEYZMPpFgtrCDSnERWIXEZ7mHE/YWiRGyjWTUnwxLh0VK vlXUUSf4v6HU9yUUDUfApxDvieOwmcp+N0FkFhW93bTp9N4xTVCmnDtCtN7Cs3nT WsjUl5lG9shXkHzfE034PP4d3tP+yxIoNt3nZDtFEco2zAKhHi8kRv7W9Lb5GuMB JbvtJWgjKVpIOhoimW6OwjXMBIQ3FIcN6cdqlpwgX/pr2TTbb6fRXImyLgjvkH9d mLRjM5zvLzPW5rEw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ad8772c6 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Fri, 15 Jun 2018 20:22:27 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id k190-v6so9895106oib.9 for ; Fri, 15 Jun 2018 13:27:51 -0700 (PDT) X-Gm-Message-State: APt69E2YfEtuUF8NX+tcCKNYte7AWuhsQA5BFp2Fa7/IVtSVB1/mCbgW CgPagty3VscS38KScaelNc4MBBtCACzg+ldUiJw= X-Received: by 2002:aca:4d0c:: with SMTP id a12-v6mr1671304oib.37.1529094470628; Fri, 15 Jun 2018 13:27:50 -0700 (PDT) MIME-Version: 1.0 References: <6eecf873-9d87-5345-70ba-5c064a31714b@linux.intel.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Fri, 15 Jun 2018 22:27:39 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Lazy FPU restoration / moving kernel_fpu_end() to context switch To: Andrew Lutomirski Cc: dave.hansen@linux.intel.com, riel@surriel.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:53 PM Andy Lutomirski wrote: > > On Fri, Jun 15, 2018 at 11:50 AM Dave Hansen > wrote: > Even with the modified optimization, kernel_fpu_end() still needs to > reload the state that was trashed by the kernel FPU use. If the > kernel is using something like AVX512 state, then kernel_fpu_end() > will transfer an enormous amount of data no matter how clever the CPU > is. And I think I once measured XSAVEOPT taking a hundred cycles or > so even when RFBM==0, so it's not exactly super fast. Indeed the speed up is really significant, especially for the AVX512 case. Here are some numbers from my laptop and a server taken a few seconds ago: AVX2 - Intel(R) Xeon(R) CPU E3-1505M v5 @ 2.80GHz Inside: 684617437 Outside: 547710093 Percent speedup: 24 AVX512 - Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz Inside: 634415672 Outside: 286698960 Percent speedup: 121 This is from this test -- https://xn--4db.cc/F7RF2fhv/c . There are probably various issues with that test case, and it's possible there are other effects going on (the avx512 case looks particularly insane) to make the difference _that_ drastic, but I think there's no doubt that the optimization here is a meaningful one.