Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1738244imu; Wed, 28 Nov 2018 14:22:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOpyHoirdaxyFGJZdOW8oUVvqQeEHIfj9r//G2ajpJIxFpbIiMttdF+N0eibbth+xM8ldU X-Received: by 2002:a17:902:d70b:: with SMTP id w11mr24725328ply.294.1543443751878; Wed, 28 Nov 2018 14:22:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543443751; cv=none; d=google.com; s=arc-20160816; b=Df+k/ABIPze4USQ8/KLLr/oY7X7aA+aU2tSB6z+ymbzHeHZxqAohZ6UY/f6+v7stFf UdstK/dYa2l6ytXSKwV60hNKIjyooJFxvZ1nxkSpFiJwwwcwMMs+qX+dyQjuUVZbaAaZ NuCszBEpP5nIpPvx3xWdLNKioSJMaNrFmp0avYwXPQmjoCrTstaAZrJaCqS5tgr0sEkx j7WPSrL84mQWYixL4GjQWkqympTy3hoA9DCZ6ZcjkvzF37t41Ovdsd4UE9WIKtcUAe0R v6gRjSg7HO1AqyH7TqOH0g2ddaXp076xdu/edh9qWL6zTUHnyEIvhwMYGjY422ONPFNn mCYQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9S4yRkfxZpJCYZNLpbw0ugdgqzMUB2BfKCQH/VG5CWs=; b=Ir6oO7HTcfa7dSfw0OyjHxu6ROWnz6gqxSMzAosZk4RbnKTZOR3Yxz2kfwC44+cW0i mdUdtfo4yqZwdaQ+IqrpS1scSNAe16A6L5nC/Tf3bNbdM640dqeKa72p3/129LXNbMnK vsJvpeH35PmmRURnHjyTM9azATYLiz7ELNnHMdFR61H3G2dv4g79UMmw2uxl9RUrNvCu GbhZkSSAJUzCEBkPu4wy/KMAShVtB2KPtwQEp+CM7GfIxao/il8li8ubBkh9OajgK7dB ZH64j7NDcHMI6kcdkN0bkA/EMOey2YUQ1aB6EhVc208yUKkkxuq7Xmyg9M5n1E4trr0C xvGA== 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 w7si9292364ply.421.2018.11.28.14.22.16; Wed, 28 Nov 2018 14:22:31 -0800 (PST) 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 S1727169AbeK2JYc (ORCPT + 99 others); Thu, 29 Nov 2018 04:24:32 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:33184 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbeK2JYb (ORCPT ); Thu, 29 Nov 2018 04:24:31 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gS8Cq-0001GX-Of; Wed, 28 Nov 2018 23:21:17 +0100 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 , Dave Hansen , Sebastian Andrzej Siewior Subject: [PATCH 20/29] x86/pkeys: Don't check if PKRU is zero before writting it Date: Wed, 28 Nov 2018 23:20:26 +0100 Message-Id: <20181128222035.2996-21-bigeasy@linutronix.de> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181128222035.2996-1-bigeasy@linutronix.de> References: <20181128222035.2996-1-bigeasy@linutronix.de> 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 write_pkru() checks if the current value is the same as the expected value. So instead just checking if the current and new value is zero (and skip the write in such a case) we can benefit from that. Remove the zero check of PKRU, write_pkru() provides a similar check. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/mm/pkeys.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c index 05bb9a44eb1c3..50f65fc1b9a3f 100644 --- a/arch/x86/mm/pkeys.c +++ b/arch/x86/mm/pkeys.c @@ -142,13 +142,6 @@ u32 init_pkru_value = PKRU_AD_KEY( 1) | PKRU_AD_KEY( 2) | PKRU_AD_KEY( 3) | void copy_init_pkru_to_fpregs(void) { u32 init_pkru_value_snapshot = READ_ONCE(init_pkru_value); - /* - * Any write to PKRU takes it out of the XSAVE 'init - * state' which increases context switch cost. Avoid - * writing 0 when PKRU was already 0. - */ - if (!init_pkru_value_snapshot && !read_pkru()) - return; /* * Override the PKRU state that came from 'init_fpstate' * with the baseline from the process. -- 2.20.0.rc1