Skip to contentSkip to conversation

xen: PV on HVM: support PV spinlocks

PATCH Stefano Stabellini 2 participants 4 messages Aug 13, 2010 – Aug 16, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

xen: PV on HVM: support PV spinlocks

arch/x86/xen/enlighten.c +17 -0
index 6f53453..5643c43 100644
@@ -1290,6 +1290,8 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_UP_PREPARE:
 		per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
+		if (xen_have_vector_callback)
+			xen_init_lock_cpu(cpu);
 		break;
 	default:
 		break;
@@ -1301,6 +1303,20 @@ static struct notifier_block __cpuinitdata xen_hvm_cpu_notifier = {
 	.notifier_call	= xen_hvm_cpu_notify,
 };
 
+static void xen_hvm_spinlock_init(void)
+{
+	if (!xen_have_vector_callback)
+		return
+	xen_init_lock_cpu(0);
+	xen_init_spinlocks();
+}
+
+static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
+{
+	xen_hvm_spinlock_init();
+	native_smp_prepare_cpus(max_cpus);
+}
+
 static void __init xen_hvm_guest_init(void)
 {
 	int r;
@@ -1320,6 +1336,7 @@ static void __init xen_hvm_guest_init(void)
 	x86_init.irqs.intr_init = xen_init_IRQ;
 	xen_hvm_init_time_ops();
 	xen_hvm_init_mmu_ops();
+	smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
 }
 
 static bool __init xen_hvm_platform(void)
#1 lore raw
Quoted 9 lines · Stefano Stabellini

xen: PV on HVM: support PV spinlocks

arch/x86/xen/enlighten.c +0 -0
index 6f53453..5643c43 100644

arch/x86/xen/enlighten.c static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, · line 1294

Quoted 5 lines
arch/x86/xen/enlighten.c +2 -0
@@ -1290,6 +1290,8 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_UP_PREPARE:
 		per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
+		if (xen_have_vector_callback)
+			xen_init_lock_cpu(cpu);

Why does this depend on vector_callback? pv spinlocks never have events actually delivered.

Nice and simple otherwise.

J

Quoted 38 lines
arch/x86/xen/enlighten.c +15 -0
 		break;
 	default:
 		break;
@@ -1301,6 +1303,20 @@ static struct notifier_block __cpuinitdata xen_hvm_cpu_notifier = {
 	.notifier_call	= xen_hvm_cpu_notify,
 };
 
+static void xen_hvm_spinlock_init(void)
+{
+	if (!xen_have_vector_callback)
+		return
+	xen_init_lock_cpu(0);
+	xen_init_spinlocks();
+}
+
+static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
+{
+	xen_hvm_spinlock_init();
+	native_smp_prepare_cpus(max_cpus);
+}
+
 static void __init xen_hvm_guest_init(void)
 {
 	int r;
@@ -1320,6 +1336,7 @@ static void __init xen_hvm_guest_init(void)
 	x86_init.irqs.intr_init = xen_init_IRQ;
 	xen_hvm_init_time_ops();
 	xen_hvm_init_mmu_ops();
+	smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
 }
 
 static bool __init xen_hvm_platform(void)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 5 lines · Jeremy Fitzhardinge
Quoted 4 lines · Stefano Stabellini

xen: PV on HVM: support PV spinlocks

Quoted 14 lines

arch/x86/xen/enlighten.c static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, · line 1294

Quoted 10 lines
arch/x86/xen/enlighten.c +2 -0
index 6f53453..5643c43 100644
@@ -1290,6 +1290,8 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_UP_PREPARE:
 		per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
+		if (xen_have_vector_callback)
+			xen_init_lock_cpu(cpu);

Why does this depend on vector_callback? pv spinlocks never have events actually delivered.

HVM guests cannot receive events on vcpus other than 0 without vector_callback, this means they wouldn't receive even a vcpu_kick and would get stuck.

#3 lore raw
Quoted 19 lines · Stefano Stabellini
Quoted 5 lines · Jeremy Fitzhardinge
Quoted 4 lines · Stefano Stabellini

xen: PV on HVM: support PV spinlocks

Quoted 13 lines

arch/x86/xen/enlighten.c static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, · line 1294

Quoted 10 lines
arch/x86/xen/enlighten.c +2 -0
index 6f53453..5643c43 100644
@@ -1290,6 +1290,8 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_UP_PREPARE:
 		per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
+		if (xen_have_vector_callback)
+			xen_init_lock_cpu(cpu);

Why does this depend on vector_callback? pv spinlocks never have events actually delivered.

Quoted 3 lines

HVM guests cannot receive events on vcpus other than 0 without vector_callback, this means they wouldn't receive even a vcpu_kick and would get stuck.

Huh, really. So if a vcpu is blocked in a poll hypercall on a masked event channel and you send that vcpu an IPI, the poll won't unblock unless you have a delivery vector?

OK, I guess.

J