Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5474843imm; Wed, 12 Sep 2018 06:35:14 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdac2W7ZCpL8UU/xPHbw7LFVqmTdZ7m+o8Fye7Y0QQ6lZ7ODvlSgtQ7pI9BDpdiKYe/T+bO2 X-Received: by 2002:a62:938e:: with SMTP id r14-v6mr2450159pfk.55.1536759314753; Wed, 12 Sep 2018 06:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536759314; cv=none; d=google.com; s=arc-20160816; b=e9cTH5X6ag4DmR0TG7m7XCjhkz0JuiJY6qXE+dT3GPIrAskBxtlhA/ktv4xaXKhCP6 dgspkNIHwIjNa5B9m+3HSsmRVeRfMV8d97wt6sKW0neq8AdoofOj1P0FZzAHsqVunsUs kyeeHNtPzkjzl0PnhJYTVC2uI2eSObvdnJHMo2kqXZTAzJbAoDhT+3p7moKwQbTdZUlY zG8pWYYvvJGWhP0Fu9TqEXOV36lgPKv8GBFgaTVuolsQagsVw5RrduOMXNjOdZy/24aV SpwovxGs9Xr+YJCpa98PiUXbIjNoA7/Xutec7icxpObowzRj4Z8WwJ9e08qcF0XApLmW NSKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=P+PJ2cExAxxpc3g5aQLzS9fSA/kKW4ytMmjz/LBmsSk=; b=Pxa3Amp6T2bBxUojMOJBJcicYcEP36wpnmANVFWrOklfxdg84WP2uDcACieSd4ynIu 6rh4NUJPEWkJ1aK1j9UmNFZdrLl6T6rlR2/pI+/FH4DG+6msRquAIXr7cM053coolihZ kYX3plqnvSN5eZBRtP7q4MMLMOPhMmenL5DHpizTXMyNROgxttti9fnKLodvEI7xE6lX xn4LwAjpkmd94UyX+XNQARuYFzsr56Ox0nFh7EOl0mB3Qnu+6a2t2h41Th0UIauE304I t8eZ8H+Z9FxS1z4dA+H3ZFi3aXPhGLUok9udtMVRIyrHaP5vBgFYtxixgG21I6p07Oa+ JIyw== 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 a23-v6si1157622pgd.235.2018.09.12.06.34.54; Wed, 12 Sep 2018 06:35:14 -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 S1728014AbeILSiv (ORCPT + 99 others); Wed, 12 Sep 2018 14:38:51 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43861 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbeILSiv (ORCPT ); Wed, 12 Sep 2018 14:38:51 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1g05Ha-0001Ap-RZ; Wed, 12 Sep 2018 15:34:14 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel Subject: [RFC PATCH] x86: load FPU registers on return to userland Date: Wed, 12 Sep 2018 15:33:43 +0200 Message-Id: <20180912133353.20595-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a refurbished series originally started by by Rik van Riel. The goal is load the FPU registers on return to userland and not on every context switch. By this optimisation we can: - avoid loading the registers if the task stays in kernel and does not return to userland - make kernel_fpu_begin() cheaper: it only saves the registers on the first invocation. The second invocation does not need save them again. To access the FPU registers in kernel we need: - disable preemption to avoid that the scheduler switches tasks. By doing so it would set TIF_LOAD_FPU and the FPU registers would be not valid. - disable BH because the softirq might use kernel_fpu_begin() and then set TIF_LOAD_FPU instead loading the FPU registers on completion. This seems to work with userland & xmm registers. Haven't tested the pkeys feature and KVM yet. Sebastian