Re: [PATCH v3 1/2] x86, lib: Add WBNOINVD helper functions
From: Dave Hansen
Date: Tue Jan 21 2025 - 19:32:51 EST
On 1/21/25 16:13, Kevin Loughlin wrote:
> +static __always_inline void wbnoinvd(void)
> +{
> + alternative("wbinvd", "wbnoinvd", X86_FEATURE_WBNOINVD);
> }
Could we please comment this a _bit_?
/*
* Cheaper version of wbinvd(). Call when caches
* need to be written back but not invalidated.
*/
static __always_inline void wbnoinvd(void)
{
/*
* Use the compatible but more destructuve "invalidate"
* variant when no-invalidate is unavailable:
*/
alternative("wbinvd", "wbnoinvd", X86_FEATURE_WBNOINVD);
}
Sure, folks can read the instruction reference, but it doesn't give you
much of the story of why you should use one over the other or why it's
OK to call one when you ask for the other.