Skip to contentSkip to conversation

linux-2.6.18/evtchn: clear secondary CPUs' cpu_evtchn_mask[] after restore

PATCH In review Jan Beulich 3 participants 4 messages Nov 15, 2010 – Nov 16, 2010 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-2.6.18/evtchn: clear secondary CPUs' cpu_evtchn_mask[] after restore

To bind all event channels to CPU#0, it is not sufficient to set all of its cpu_evtchn_mask[] bits; all other CPUs also need to get their bits cleared. Otherwise, evtchn_do_upcall() will start handling interrupts on CPUs they're not intended to run on, which can be particularly bad for per-CPU ones.

drivers/xen/core/evtchn.c +2 -1
@@ -161,7 +161,8 @@ static void init_evtchn_cpu_bindings(voi
 		set_native_irq_info(i, cpumask_of_cpu(0));
 
 	memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
-	memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0]));
+	for_each_possible_cpu(i)
+		memset(cpu_evtchn_mask[i], -!i, sizeof(cpu_evtchn_mask[i]));
 }
 
 static inline unsigned int cpu_from_evtchn(unsigned int evtchn)

To bind all event channels to CPU#0, it is not sufficient to set all of its cpu_evtchn_mask[] bits; all other CPUs also need to get their bits cleared. Otherwise, evtchn_do_upcall() will start handling interrupts on CPUs they're not intended to run on, which can be particularly bad for per-CPU ones.

drivers/xen/core/evtchn.c +2 -1
@@ -161,7 +161,8 @@ static void init_evtchn_cpu_bindings(voi
 		set_native_irq_info(i, cpumask_of_cpu(0));
 
 	memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
-	memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0]));
+	for_each_possible_cpu(i)
+		memset(cpu_evtchn_mask[i], -!i, sizeof(cpu_evtchn_mask[i]));
 }
 
 static inline unsigned int cpu_from_evtchn(unsigned int evtchn)

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

#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

To bind all event channels to CPU#0, it is not sufficient to set all of its cpu_evtchn_mask[] bits; all other CPUs also need to get their bits cleared. Otherwise, evtchn_do_upcall() will start handling interrupts on CPUs they're not intended to run on, which can be particularly bad for per-CPU ones.

I believe this also needs to be fixed in the pv-ops sources.

Furthermore, while debugging this, I looked at pv-ops' implementation of bind_evtchn_to_cpu(), and I suspect that the use of __clear_bit() and __set_bit() isn't correct there - looking over the call sites there doesn't appear to be a common serializing spinlock. If so the underscore-less variants ought to be used.

Jan

#2 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich

To bind all event channels to CPU#0, it is not sufficient to set all of its cpu_evtchn_mask[] bits; all other CPUs also need to get their bits cleared. Otherwise, evtchn_do_upcall() will start handling interrupts on CPUs they're not intended to run on, which can be particularly bad for per-CPU ones.

Yes, that would be awkward.

drivers/xen/core/evtchn.c static void init_evtchn_cpu_bindings(voi · line 165

Quoted 11 lines
drivers/xen/core/evtchn.c +2 -1
@@ -161,7 +161,8 @@ static void init_evtchn_cpu_bindings(voi
 		set_native_irq_info(i, cpumask_of_cpu(0));
 
 	memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
-	memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0]));
+	for_each_possible_cpu(i)
+		memset(cpu_evtchn_mask[i], -!i, sizeof(cpu_evtchn_mask[i]));

-!i? Really? Golf-clap and all, but I think something a bit more explicit would be better ;)

J

#3 lore raw
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 4 lines · Jan Beulich

memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
- memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0]));
+ for_each_possible_cpu(i)
+ memset(cpu_evtchn_mask[i], -!i, sizeof(cpu_evtchn_mask[i]));

-!i? Really? Golf-clap and all, but I think something a bit more explicit would be better ;)

I'm going to clarify that bit when I apply to 2.6.18. :-)

-- Keir

Quoted 6 lines

J

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