From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: [PATCH 12/22] x86/fpu: Only write PKRU if it is different from current Date: Wed, 23 Jan 2019 10:09:24 -0800 Message-ID: References: <20190109114744.10936-1-bigeasy@linutronix.de> <20190109114744.10936-13-bigeasy@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel , Dave Hansen To: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org Return-path: In-Reply-To: <20190109114744.10936-13-bigeasy@linutronix.de> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 1/9/19 3:47 AM, Sebastian Andrzej Siewior wrote: > +static inline void __write_pkru(u32 pkru) > +{ > + /* > + * Writting PKRU is expensive. Only write the PKRU value if it is > + * different from the current one. > + */ I'd say: WRPKRU is relatively expensive compared to RDPKRU. Avoid WRPKRU when it would not change the value. In the grand scheme of things, WRPKRU is cheap. It's certainly not an "expensive instruction" compared to things like WBINVD. > + if (pkru == __read_pkru()) > + return; > + __write_pkru_insn(pkru); > +} Is there a case where we need __write_pkru_insn() directly? Why not just put the inline assembly in here?