Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp613095imm; Wed, 26 Sep 2018 04:13:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61wYFHcx8gwTp5elJWHr5kVW53A2uww8WEnz75BSDgKHu5Ba1j8BBxpNGjoSahGfNWcD3fI X-Received: by 2002:a63:c14a:: with SMTP id p10-v6mr5212449pgi.305.1537960409629; Wed, 26 Sep 2018 04:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537960409; cv=none; d=google.com; s=arc-20160816; b=raOydnGd9flaWzMwA1oevd/ey6gx3iCNhK3W1pffC4anSuf0VSmjbI4WWpVzWa41aP rcKppfvNXZTUyvGmQPPyqZhGHZTavkdgbO++jyCqqLMEGPZiSWlVeb0DioT0MFOr42IK 3G8G0aUjOy5CtJPxeHPZZorJsbffCuSgL4JnpTxT6T/16f/HaJ4FEVU3XZHZnDoFQg3Z sdjYKQtKc+2w25Xj0BPbc4uN1N/mTWpA6nSgRkB8hAG3O1VgZgrebIJIRs98UjPoNvkI sXAGu3REmfKdSAH7nXnxF0+g16dGaX7MgYxl3H2GLiQ4msltIW6+eamKLZ0dO1amdIQk +lSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=QNFmZeo1O4tcVPtlqJhG3Urvf1yx7ayLXyHL7rW4Tns=; b=yxmZsJtAdPTGtH52girLFgaBN39yl4KWxPLU+OhWQp7lkpYIGwQ73tue6VQKpWdih+ pgLSccx9EhJ0d1Fnt2ET9uwjfHWBpuh2y5r7vtIeSJrEsZifDN55UO1QLMgIz3/lIAKK RZQltOS9ml3WDXOwGqW5WDL2oCArgfUVs5RAAUGB0NHQHYlrH87mz8PUE919yL2YoEkj 0cPXbtjFUHqrncoi4/Sj4v09IwsiD4jsBPRjSbIJNv8SGW8CTLUo0Ve7m2nNGuIyEZqh hFHw8TKgHAQhL2fM/X37UVqB7el22TLW8Zi3ZfmGKHLvkbMoWX/crFra5HZMGZwW7ATx xeIQ== 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 t9-v6si5028656pgr.244.2018.09.26.04.13.13; Wed, 26 Sep 2018 04:13:29 -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 S1727873AbeIZRY5 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 26 Sep 2018 13:24:57 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49220 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbeIZRY4 (ORCPT ); Wed, 26 Sep 2018 13:24:56 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1g57jz-0004VH-8g; Wed, 26 Sep 2018 13:12:23 +0200 Date: Wed, 26 Sep 2018 13:12:23 +0200 From: Sebastian Andrzej Siewior To: Andy Lutomirski Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel Subject: Re: [RFC PATCH 10/10] x86/fpu: defer FPU state load until return to userspace Message-ID: <20180926111222.hihueuagmb4qfmtz@linutronix.de> References: <20180912133353.20595-1-bigeasy@linutronix.de> <20180912133353.20595-11-bigeasy@linutronix.de> <650FC457-7E4C-473A-9E5F-EAFC74F6444B@amacapital.net> <20180919170515.ptqmmpsxrdjsi64j@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-09-20 21:15:35 [-0700], Andy Lutomirski wrote: > > I mean the fpu.initialized variable entirely. AFAIK, its only use is for kernel threads — setting it to false lets us switch to a kernel thread and back without saving and restoring. But TIF_LOAD_FPU should be able to replace it: when we have FPU regs loaded and we switch to *any* thread, kernel or otherwise, we can set TIF_LOAD_FPU and leave the old regs loaded. So we don’t need the special case for kernel threads. > > > > Which reminds me: if you haven’t already done so, can you add a helper to sanity check the current context? It should check that the combination of owner_ctx, last_cpu, and TIF_LOAD_FPU is sane. For example, if owner_ctx or last_cpu is says the cpu regs are invalid for current but TIF_LOAD_FPU is clear, it should warn. I think that at least switch_fpu_finish should call it. Arguably switch_fpu_prepare should too, at the beginning. > > Looking some more, the “preload” variable needs to go away or be renamed. It hasn’t had anything to do with preloading for some time. okay. > Also, the interaction between TIF_LOAD_FPU and FPU emulation needs to be documented somewhere. Probably FPU-less systems should never have TIF_LOAD_FPU set. Yes, they should not. > Or we could decide that no one uses FPU emulation any more. Oh. Removing unused code? I'm all yours. There is this Intel Quark thingy which comes to mind can still be bought. Its data sheet[0] has this: | 13.1 Features: | Note: The processor does not provide an x87 Floating Point Unit (FPU) and does | not support x87 FPU instructions so not only it does not support the lock prefix, no, it also relies on soft-FPU. The latest bsp release notes quotes a package named quark_linux_v3.14+v1.2.1.1.tar.gz so they still use v3.14 (which is not a supported kernel anymore). And then I took a look into their Yocto-BSP and found this: | $ fgrep -R MATH_EMULATION . | ./meta-intel-quark/recipes-kernel/linux/files/quark_3.14.cfg:# CONFIG_MATH_EMULATION is not set so they don't set this option. This is small SoC and does not run on any Distro due to the missing lock prefix. So if they use yocto to recompile everything, they can rebuild their toolchain with soft-fpu support which is more efficient than calling into the kernel for every opcode. So I *think* nobody relies on FPU-emulation anymore. I would suggest to get this patch set into shape and then getting rid of CONFIG_MATH_EMULATION? [0] https://www.intel.de/content/dam/www/public/us/en/documents/datasheets/quark-c1000-datasheet.pdf [1] https://downloadmirror.intel.com/23197/eng/Quark_SW_RelNotes_330232_007.pdf Sebastian