Re: [PATCH v4 1/4] x86/kvm: Add "nopvspin" parameter to disable PV spinlocks

From
Zhenzhong Duan <hidden>
Date
2019-10-08 02:20:41
Also in
kvm, lkml
Reply to
Boris Ostrovsky, 2019-10-07
On 2019/10/7 22:46, Boris Ostrovsky wrote:
On 10/6/19 3:49 AM, Zhenzhong Duan wrote:
quoted
On 2019/10/4 22:52, Boris Ostrovsky wrote:
quoted
On 10/3/19 10:02 AM, Zhenzhong Duan wrote:
quoted
   void __init kvm_spinlock_init(void)
   {
-    /* Does host kernel support KVM_FEATURE_PV_UNHALT? */
-    if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
-        return;
-
-    if (kvm_para_has_hint(KVM_HINTS_REALTIME))
+    /*
+     * Don't use the pvqspinlock code if no KVM_FEATURE_PV_UNHALT
feature
+     * support, or there is REALTIME hints or only 1 vCPU.
+     */
+    if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT) ||
+        kvm_para_has_hint(KVM_HINTS_REALTIME) ||
+        num_possible_cpus() == 1) {
+        pr_info("PV spinlocks disabled\n");
           return;
+    }
   -    /* Don't use the pvqspinlock code if there is only 1 vCPU. */
-    if (num_possible_cpus() == 1)
+    if (nopvspin) {
+        pr_info("PV spinlocks disabled forced by \"nopvspin\"
parameter.\n");
+        static_branch_disable(&virt_spin_lock_key);
Would it make sense to bring here the other site where the key is
disabled (in kvm_smp_prepare_cpus())?
Thanks for point out, I'll do it. Just not clear if I should do that
in a separate patch,
there is a history about that code:

Its original place was here and then moved to kvm_smp_prepare_cpus()
by below commit:
34226b6b ("KVM: X86: Fix setup the virt_spin_lock_key before static
key get initialized")
which fixed jump_label_init() calling late issue.

Then 8990cac6 ("x86/jump_label: Initialize static branching early")
move jump_label_init()
early, so commit 34226b6b could be reverted.
Which is similar to what you did earlier for Xen.
You remember that, ok, I'll do the same for KVM.

Thanks

Zhenzhong
Thread (12 messages) 12 messages, 3 authors, last reply 2019-10-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help