]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: Protect vCPU's "last run PID" with rwlock, not RCU
authorSean Christopherson <seanjc@google.com>
Fri, 2 Aug 2024 20:01:36 +0000 (13:01 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 30 Oct 2024 21:41:22 +0000 (14:41 -0700)
commit3e7f43188ee227bcf0f07f60a00f1fd1aca10e6a
tree2352d8d8028028066b4903e3c2b4dc2cce71952f
parent6cf9ef23d9428ca4950a818e3e70bd818748815a
KVM: Protect vCPU's "last run PID" with rwlock, not RCU

To avoid jitter on KVM_RUN due to synchronize_rcu(), use a rwlock instead
of RCU to protect vcpu->pid, a.k.a. the pid of the task last used to a
vCPU.  When userspace is doing M:N scheduling of tasks to vCPUs, e.g. to
run SEV migration helper vCPUs during post-copy, the synchronize_rcu()
needed to change the PID associated with the vCPU can stall for hundreds
of milliseconds, which is problematic for latency sensitive post-copy
operations.

In the directed yield path, do not acquire the lock if it's contended,
i.e. if the associated PID is changing, as that means the vCPU's task is
already running.

Reported-by: Steve Rutherford <srutherford@google.com>
Reviewed-by: Steve Rutherford <srutherford@google.com>
Acked-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240802200136.329973-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/arm64/include/asm/kvm_host.h
include/linux/kvm_host.h
virt/kvm/kvm_main.c