Skip to content

Commit 7477565

Browse files
lrq-maxbonzini
authored andcommitted
KVM: use cpu_relax when halt polling
SMT siblings share caches and other hardware, and busy halt polling will degrade its sibling performance if its sibling is working Sean Christopherson suggested as below: "Rather than disallowing halt-polling entirely, on x86 it should be sufficient to simply have the hardware thread yield to its sibling(s) via PAUSE. It probably won't get back all performance, but I would expect it to be close. This compiles on all KVM architectures, and AFAICT the intended usage of cpu_relax() is identical for all architectures." Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Li RongQing <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5868b82 commit 7477565

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

virt/kvm/kvm_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,6 +3110,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
31103110
++vcpu->stat.generic.halt_poll_invalid;
31113111
goto out;
31123112
}
3113+
cpu_relax();
31133114
poll_end = cur = ktime_get();
31143115
} while (kvm_vcpu_can_poll(cur, stop));
31153116
}

0 commit comments

Comments
 (0)