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

Kevin Loughlin
2025-01-22T01:14:29Z

On Tue, Jan 21, 2025 at 4:32 PM Dave Hansen <dave.hansen@intel.com> wrote:
>
> 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.

Yeah, good point. Incoming in v4; thanks!