KVM: PPC: Book3S HV: Fix race in starting secondary threads
A message that is not in the archive (sent off-list or not yet received): [email protected]
David Gibson
Reviewed-byQuoted 19 lines · Paul Mackerras
From: "Gautham R. Shenoy" <[email protected]>
The current dynamic micro-threading code has a race due to which a secondary thread naps when it is supposed to be running a vcpu. As a side effect of this, on a guest exit, the primary thread in
kvmppc_wait_for_nap()finds that this secondary thread hasn't cleared its vcore pointer. This results in "CPU X seems to be stuck!" warnings.The race is possible since the primary thread on exiting the guests only waits for all the secondaries to clear its vcore pointer. It subsequently expects the secondary threads to enter nap while it unsplits the core. A secondary thread which hasn't yet entered the nap will loop in
kvm_no_guestuntil its vcore pointer and thedo_napflag are unset. Once the core has been unsplit, a new vcpu thread can grab the core and set thedo_napflag *before* setting the vcore pointers of the secondary. As a result, the secondary thread will now enter nap viakvm_unsplit_napinstead of running the guest vcpu.
Quoted 8 lines
Fix this by setting the
do_napflag after setting the vcore pointer in the PACA of the secondary inkvmppc_run_core. Also, ensure that a secondary thread doesn't nap inkvm_unsplit_napwhen the vcore pointer in its PACA struct is set.Fixes b4deba5c41e9Signed-off-by Gautham R. Shenoy <[email protected]>Signed-off-by Paul Mackerras <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson