Re: [PATCH] x86: kvm: Initialize static calls before SMP boot
From: Paolo Bonzini
Date: Fri Mar 06 2026 - 06:20:18 EST
Il mer 4 mar 2026, 20:19 Sean Christopherson <seanjc@xxxxxxxxxx> ha scritto:
>
> On Wed, Mar 04, 2026, David Sauerwein wrote:
> > Updating static calls is expensive on wide SMP systems because all
> > online CPUs need to act in a coordinated manner for code patching to
> > work as expected.
>
> Eww. I am very, very against an early_initcall() in KVM, even if we pinky swear
> we'll never use it for anything except prefetching static_call() targets. The
> initcall framework lacks the ability to express dependencies, and KVM most definitely
> has dependencies on arch and subsys code.
>
> I also don't like hacking KVM to workaround what is effectively a generic
> infrastructure issue/limitation.
>
> Have y'all looked at Valentin's series to defer IPIs? I assume/hope deferring
> IPIs would reduce the delay observed when doing the patching.
x86 has a smp_text_poke_batch_finish() function, maybe it could be
exposed as arch_static_call_batch_finish() too?
Then you add a __static_call_update_batch_add() function, and
__static_call_update() becomes
__static_call_update_batch_add(key, tramp, func);
arch_static_call_batch_finish();
to limit the amount of synchronization.
The next step would be to expose the batch functionality and allow
patching multiple static calls at once. I'm not sure where things stop
being useful, though.
Paolo