diff mbox series

[RFC,09/14] KVM: x86: Move shared KVM state into VAC

Message ID 20231107202002.667900-10-aghulati@google.com (mailing list archive)
State New, archived
Headers show
Series Support multiple KVM modules on the same host | expand

Commit Message

Anish Ghulati Nov. 7, 2023, 8:19 p.m. UTC
From: Venkatesh Srinivas <venkateshs@chromium.org>

Move kcpu_kick_mask and vm_running_vcpu* from arch neutral KVM code into
VAC.

TODO: Explain why this needs to be moved into VAC.

Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
Signed-off-by: Anish Ghulati <aghulati@google.com>
---
 virt/kvm/kvm_main.c | 6 ++++--
 virt/kvm/vac.c      | 5 +++++
 virt/kvm/vac.h      | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

Comments

Lai Jiangshan Nov. 17, 2023, 8:54 a.m. UTC | #1
On Wed, Nov 8, 2023 at 4:21 AM Anish Ghulati <aghulati@google.com> wrote:
>
> From: Venkatesh Srinivas <venkateshs@chromium.org>
>
> Move kcpu_kick_mask and vm_running_vcpu* from arch neutral KVM code into
> VAC.

Hello, Venkatesh, Anish

IMO, the allocation code for cpu_kick_mask has to be moved too.

Thanks

Lai
Sean Christopherson Nov. 28, 2023, 6:01 p.m. UTC | #2
On Fri, Nov 17, 2023, Lai Jiangshan wrote:
> On Wed, Nov 8, 2023 at 4:21 AM Anish Ghulati <aghulati@google.com> wrote:
> >
> > From: Venkatesh Srinivas <venkateshs@chromium.org>
> >
> > Move kcpu_kick_mask and vm_running_vcpu* from arch neutral KVM code into
> > VAC.
> 
> Hello, Venkatesh, Anish
> 
> IMO, the allocation code for cpu_kick_mask has to be moved too.

I'm pretty sure this patch should be dropped.  I can't think of any reason why
cpu_kick_mask needs to be in VAC, and kvm_running_vcpu definitely needs to be
per-KVM.
diff mbox series

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index fb50deaad3fd..575f044fd842 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -108,7 +108,6 @@  LIST_HEAD(vm_list);
 static struct kmem_cache *kvm_vcpu_cache;
 
 static __read_mostly struct preempt_ops kvm_preempt_ops;
-static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_running_vcpu);
 
 struct dentry *kvm_debugfs_dir;
 EXPORT_SYMBOL_GPL(kvm_debugfs_dir);
@@ -150,7 +149,10 @@  static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm);
 static unsigned long long kvm_createvm_count;
 static unsigned long long kvm_active_vms;
 
-static DEFINE_PER_CPU(cpumask_var_t, cpu_kick_mask);
+__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,
+						   unsigned long start, unsigned long end)
+{
+}
 
 __weak void kvm_arch_guest_memory_reclaimed(struct kvm *kvm)
 {
diff --git a/virt/kvm/vac.c b/virt/kvm/vac.c
index ff034a53af50..c628afeb3d4b 100644
--- a/virt/kvm/vac.c
+++ b/virt/kvm/vac.c
@@ -6,6 +6,11 @@ 
 #include <linux/percpu.h>
 #include <linux/mutex.h>
 
+DEFINE_PER_CPU(cpumask_var_t, cpu_kick_mask);
+EXPORT_SYMBOL(cpu_kick_mask);
+
+DEFINE_PER_CPU(struct kvm_vcpu *, kvm_running_vcpu);
+
 #ifdef CONFIG_KVM_GENERIC_HARDWARE_ENABLING
 DEFINE_MUTEX(vac_lock);
 
diff --git a/virt/kvm/vac.h b/virt/kvm/vac.h
index aed178a16bdb..f3e7b08168df 100644
--- a/virt/kvm/vac.h
+++ b/virt/kvm/vac.h
@@ -29,4 +29,7 @@  static inline void hardware_disable_all(void)
 }
 #endif /* CONFIG_KVM_GENERIC_HARDWARE_ENABLING */
 
+DECLARE_PER_CPU(cpumask_var_t, cpu_kick_mask);
+DECLARE_PER_CPU(struct kvm_vcpu *, kvm_running_vcpu);
+
 #endif