mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zachary Amsden <zamsden@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Zachary Amsden <zamsden@redhat.com>,
	Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH v2: kvm 4/4] Fix hotplug of CPUs for KVM.
Date: Mon, 28 Sep 2009 18:04:32 -1000	[thread overview]
Message-ID: <1254197072-889-5-git-send-email-zamsden@redhat.com> (raw)
In-Reply-To: <1254197072-889-4-git-send-email-zamsden@redhat.com>

Both VMX and SVM require per-cpu memory allocation, which is done at module
init time, for only online cpus.

Backend was not allocating enough structure for all possible CPUs, so
new CPUs coming online could not be hardware enabled.

Signed-off-by: Zachary Amsden <zamsden@redhat.com>
---
 arch/x86/kvm/svm.c  |    4 ++--
 arch/x86/kvm/vmx.c  |    6 ++++--
 virt/kvm/kvm_main.c |    3 ---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index d1036ce..02a4269 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -482,7 +482,7 @@ static __init int svm_hardware_setup(void)
 		kvm_enable_efer_bits(EFER_SVME);
 	}
 
-	for_each_online_cpu(cpu) {
+	for_each_possible_cpu(cpu) {
 		r = svm_cpu_init(cpu);
 		if (r)
 			goto err;
@@ -516,7 +516,7 @@ static __exit void svm_hardware_unsetup(void)
 {
 	int cpu;
 
-	for_each_online_cpu(cpu)
+	for_each_possible_cpu(cpu)
 		svm_cpu_uninit(cpu);
 
 	__free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER);
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3fe0d42..e86f1a6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1350,15 +1350,17 @@ static void free_kvm_area(void)
 {
 	int cpu;
 
-	for_each_online_cpu(cpu)
+	for_each_possible_cpu(cpu) {
 		free_vmcs(per_cpu(vmxarea, cpu));
+		per_cpu(vmxarea, cpu) = NULL;
+	}
 }
 
 static __init int alloc_kvm_area(void)
 {
 	int cpu;
 
-	for_each_online_cpu(cpu) {
+	for_each_possible_cpu(cpu) {
 		struct vmcs *vmcs;
 
 		vmcs = alloc_vmcs_cpu(cpu);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e27b7a9..2cd8bc2 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1716,9 +1716,6 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
 {
 	int cpu = (long)v;
 
-	if (!kvm_usage_count)
-		return NOTIFY_OK;
-
 	val &= ~CPU_TASKS_FROZEN;
 	switch (val) {
 	case CPU_DYING:
-- 
1.6.4.4


  reply	other threads:[~2009-09-29  4:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29  4:04 Hotplug / TSC cleanup and fixing Zachary Amsden
2009-09-29  4:04 ` [PATCH v2: kvm 1/4] Code motion. Separate timer intialization into an indepedent function Zachary Amsden
2009-09-29  4:04   ` [PATCH v2: kvm 2/4] Kill the confusing tsc_ref_khz and ref_freq variables Zachary Amsden
2009-09-29  4:04     ` [PATCH v2: kvm 3/4] Fix printk name error in svm.c Zachary Amsden
2009-09-29  4:04       ` Zachary Amsden [this message]
2009-09-29  8:30         ` [PATCH v2: kvm 4/4] Fix hotplug of CPUs for KVM Avi Kivity
2009-09-29 15:51           ` Zachary Amsden
2009-09-29 21:38           ` [PATCH v4: kvm 1/4] Code motion. Separate timer intialization into an indepedent function Zachary Amsden
2009-09-29 21:38             ` [PATCH v4: kvm 2/4] Kill the confusing tsc_ref_khz and ref_freq variables Zachary Amsden
2009-09-29 21:38               ` [PATCH v4: kvm 3/4] Fix printk name error in svm.c Zachary Amsden
2009-09-29 21:38                 ` [PATCH v4: kvm 4/4] Fix hotplug of CPUs for KVM Zachary Amsden
2009-09-30 13:35                   ` Marcelo Tosatti
2009-10-08 23:18               ` [PATCH v4: kvm 2/4] Kill the confusing tsc_ref_khz and ref_freq variables Jan Kiszka
2009-10-09 20:27                 ` Zachary Amsden
2009-10-09 20:36                   ` Jan Kiszka
2009-10-09 20:36                     ` Zachary Amsden
2009-10-09 20:47                       ` Jan Kiszka
2009-10-09 20:47                         ` Zachary Amsden
2009-10-09 21:05                           ` Jan Kiszka
2009-09-30  8:45             ` [PATCH v4: kvm 1/4] Code motion. Separate timer intialization into an indepedent function Avi Kivity
2009-09-30 15:51               ` Zachary Amsden
2009-09-30 15:56                 ` Avi Kivity
2009-09-30 16:06                   ` Zachary Amsden
2009-09-30 16:11                     ` Avi Kivity
2009-09-30 16:16                       ` Zachary Amsden
2009-09-29  8:29     ` [PATCH v2: kvm 2/4] Kill the confusing tsc_ref_khz and ref_freq variables Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1254197072-889-5-git-send-email-zamsden@redhat.com \
    --to=zamsden@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®