Re: [PATCH RFC 3/7] x86: kernel: cpu: bugs.c: modify static_cpu_has to boot_cpu_has
From: Thomas Gleixner
Date: Mon Jul 06 2020 - 10:46:37 EST
Mihai Carabas <mihai.carabas@xxxxxxxxxx> writes:
> The usage of static_cpu_has in bugs.c file is counter-productive
> since the code is executed once but there is extra effort to patch
> it and keep alternatives in a special section --- so there is both
> space and time cost.
>
> Quote from _static_cpu_has definition:
> /*
> * Static testing of CPU features. Used the same as boot_cpu_has(). It
> * statically patches the target code for additional performance. Use
> * static_cpu_has() only in fast paths, where every cycle counts. Which
> * means that the boot_cpu_has() variant is already fast enough for the
> * majority of cases and you should stick to using it as it is generally
> * only two instructions: a RIP-relative MOV and a TEST.
> */
>
> There are two other places where static_cpu_has is used and might be
> considered critical paths: __speculation_ctrl_update() and vmx_l1d_flush().
>
> Given these facts, changing static_cpu_has to boot_cpu_has is done in
> order to bypass alternative instructions which cannot be updated at runtime
> for now.
Not going to happen. We are not adding 4 conditionals to context switch
just to support that late loading horrors. There are better ways to do
that.
Thanks,
tglx