Re: [PATCH 0/5] x86/cpu: Introduce <asm/cpuid/types.h> and <asm/cpuid/api.h> and clean them up
From: Ingo Molnar
Date: Tue Mar 18 2025 - 14:46:53 EST
* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Tue, 18 Mar 2025 at 11:04, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
> >
> > plus we could implement the main CPUID call as:
> >
> > static inline void native_cpuid(struct cpuid_regs *cregs)
> > {
> > /* ecx is often an input as well as an output. */
> > asm volatile("cpuid"
>
> So this really needs "asm inline" now. Because if it's not inlined, it
> generates horrific code.
>
> Anyway, I agree with whoever (hpa?) said we should probably just
> unconditionally make all "asm" be "__asm__ __inline__" .
Yeah, it was hpa, and I was thinking about that approach today, and was
about to write a "don't want to do such a big binary change without
Linus's buy-in" reply ...
... and problem solved. ;-)
> And then *if* there are any places that want to out-line the asm (why
> would you do that? At that point you'd be better off just writing
> assembler!), they could use an explicit __asm__ instead with a
> comment.
>
> Sadly, I think doing just a mindless
>
> #define asm(...) __asm__ __inline__(__VA_ARGS__)
>
> doesn't work, because we also have
>
> register void *tos asm("r11");
>
> kind of patterns.
>
> So first we'd have to change those to use __asm__(), and *then* we
> could do the "asm() is always __asm__ __inline__()" thing.
Yeah, I'll try this out. Should this be done for all architectures, or
just for x86 for the time being?
I'm not sure an arch opt-in is worth it, it will only end up in the
active architectures picking it, but none of the others, and we'll live
with the duality forever.
Thanks,
Ingo