Re: [PATCH v3 1/2] x86, lib: Add WBNOINVD helper functions
From: Kevin Loughlin
Date: Tue Jan 21 2025 - 20:14:40 EST
On Tue, Jan 21, 2025 at 4:32 PM Dave Hansen <dave.hansen@xxxxxxxxx> 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!