public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM breaks CPU hotplug
@ 2007-03-26  8:48 Shaohua Li
       [not found] ` <1174898893.14063.7.camel-yAZKuqJtXNMXR+D7ky4Foa2pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Shaohua Li @ 2007-03-26  8:48 UTC (permalink / raw)
  To: kvm-devel; +Cc: Andrew Morton

When testing CPU hotplug, I found cpu can't be onlined with kvm enabled
sometimes. The reason is smp_call_function_single is a nop if the thread
is running on the target cpu. I think CPU_ONLINE case doesn't require
the fix as the online CPU isn't plugged into sheduler yet.

Signed-off-by: Shaohua Li <shaohua.li-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index dc7a8c7..806a931 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2360,6 +2360,7 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
 			   void *v)
 {
 	int cpu = (long)v;
+	int this_cpu;
 
 	switch (val) {
 	case CPU_DOWN_PREPARE:
@@ -2367,8 +2368,13 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
 		printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
 		       cpu);
 		decache_vcpus_on_cpu(cpu);
-		smp_call_function_single(cpu, kvm_arch_ops->hardware_disable,
-					 NULL, 0, 1);
+		this_cpu = get_cpu();
+		if (this_cpu == cpu)
+			kvm_arch_ops->hardware_disable(NULL);
+		else
+			smp_call_function_single(cpu,
+				kvm_arch_ops->hardware_disable,  NULL, 0, 1);
+		put_cpu();
 		break;
 	case CPU_ONLINE:
 		printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n",

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-27  6:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-26  8:48 [PATCH] KVM breaks CPU hotplug Shaohua Li
     [not found] ` <1174898893.14063.7.camel-yAZKuqJtXNMXR+D7ky4Foa2pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
2007-03-26  9:11   ` Avi Kivity
     [not found]     ` <46078E2C.9010100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-26 10:58       ` Avi Kivity
     [not found]         ` <4607A749.30603-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-27  1:12           ` Li, Shaohua
     [not found]             ` <FC1D1B23302A22499C60C967336B2AE00100CB7F-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-03-27  6:38               ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox