Re: [PATCH v3 1/2] x86, lib: Add WBNOINVD helper functions

Dave Hansen
2025-01-22T00:32:39Z

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.