[PATCH v2 4/6] KVM: Don't kick offline CPUs when making a multi-vCPU request
From: Sean Christopherson
Date: Thu Nov 19 2026 - 18:57:24 EST
Don't send IPIs to offline CPUs when sending a request to multiple vCPUs,
as it's obviously unnecessary and sending a reschedule IPI (spoiler alert)
to an offline CPU will trigger a WARN in x86's native_smp_send_reschedule().
Note, as explained in commit 85b640450ddc ("KVM: Clean up benign vcpu->cpu
data races when kicking vCPUs"), checking for an online CPU is inherently
racy, but losing the race is functionally a-ok. I.e. the goal is purely to
avoid tripping x86's WARN.
Suggested-by: Satish Kharat <satishkh@xxxxxxxxx>
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d2a858d4b8e9..07cc0dd10b71 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -265,7 +265,7 @@ static void kvm_make_vcpu_request(struct kvm_vcpu *vcpu,
*/
if (kvm_request_needs_ipi(vcpu, kick->req)) {
cpu = READ_ONCE(vcpu->cpu);
- if (cpu != -1 && cpu != kick->me) {
+ if (cpu != -1 && cpu != kick->me && cpu_online(cpu)) {
kick->need_kick = true;
__cpumask_set_cpu(cpu, kick->cpus);
}
--
2.56.1.708.g77570a6a1d-goog