[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1582859921-11932-1-git-send-email-wanpengli@tencent.com>
Date: Fri, 28 Feb 2020 11:18:41 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>
Subject: [PATCH v3] KVM: X86: Just one leader to trigger kvmclock sync request
From: Wanpeng Li <wanpengli@...cent.com>
In the progress of vCPUs creation, it queues a kvmclock sync worker to the global
workqueue before each vCPU creation completes. The workqueue subsystem guarantees
not to queue the already queued work, however, we can make the logic more clear by
make just one leader to trigger this kvmclock sync request and save on cacheline
boucing due to test_and_set_bit.
Signed-off-by: Wanpeng Li <wanpengli@...cent.com>
---
v2 -> v3:
* update patch description
v1 -> v2:
* check vcpu->vcpu_idx
arch/x86/kvm/x86.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fb5d64e..79bc995 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9390,8 +9390,9 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
if (!kvmclock_periodic_sync)
return;
- schedule_delayed_work(&kvm->arch.kvmclock_sync_work,
- KVMCLOCK_SYNC_PERIOD);
+ if (vcpu->vcpu_idx == 0)
+ schedule_delayed_work(&kvm->arch.kvmclock_sync_work,
+ KVMCLOCK_SYNC_PERIOD);
}
void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
--
2.7.4
Powered by blists - more mailing lists