Re: [PATCH v5 1/2] x86, lib: Add WBNOINVD helper functions
From: Dave Hansen
Date: Wed Jan 22 2025 - 19:36:48 EST
On 1/22/25 16:24, Kevin Loughlin wrote:
> +static __always_inline void wbnoinvd(void)
> +{
> + /*
> + * WBNOINVD is encoded as 0xf3 0x0f 0x09. Making this
> + * encoding explicit ensures compatibility with older versions of
> + * binutils, which may not know about WBNOINVD.
This kinda pokes at one of my pet peeves. It's writing a comment where
code would do. I'd *much* rather write a function that explains to you
in code that "WBNOINVD is encoded as 0xf3 0x0f 0x09":
static __always_inline void native_wbnoinvd(void)
{
asm volatile(".byte 0xf3,0x0f,0x09\n\t": : :"memory");
}
instead of writing out a comment. It's kinda silly to have to write out
the encoding explicitly in a comment and then have to rewrite it in the
code.