On 12/03/2018 15:19, Vitaly Kuznetsov wrote: >>> Static key is being used to avoid performance penalty for non-Hyper-V >>> deployments. Tests show we add around 3 (three) CPU cycles on each >>> VMEXIT (1077.5 cycles before, 1080.7 cycles after for the same CPUID >>> loop on bare metal). We can probably avoid one test/jmp in vmx_vcpu_run() >>> but I don't see a clean way to use static key in assembly. >> STATIC_JUMP_IF_TRUE, STATIC_JUMP_IF_FALSE are your friends. >> > Thanks for the tip, > > with a single kernel user of these APIs it was easy to miss :-) > > Unfortunately, these APIs are only present if HAVE_JUMP_LABEL and > (afaiu) we still care about KVM on !HAVE_JUMP_LABEL builds. It would be > nice if we can make them behave the same way static_branch_likely() and > friends do: compile into something else when !HAVE_JUMP_LABEL so we can > avoid nasty #ifdefs in C code. > > That said I'd like to defer the question to KVM maintainers: Paolo, > Radim, what would you like me to do? Use STATIC_JUMP_IF_TRUE/FALSE as > they are, try to make them work for !HAVE_JUMP_LABEL and use them or > maybe we can commit the series as-is and have it as a future > optimization (e.g. when HAVE_JUMP_LABEL becomes mandatory)? With a single instruction to patch, poking at the text manually might be an option... Otherwise, it's okay as-is. Paolo