Skip to contentSkip to conversation

linux/x86: eliminate nesting of run-queue locks inside xtime_lock

PATCH In review Jan Beulich 2 participants 3 messages Aug 10, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/x86: eliminate nesting of run-queue locks inside xtime_lock

From: Zdenek Salvet <[email protected]>

According to Debian bug 591362 this has been causing problems. While no proof was given that the inverse lock order does actually occur anywhere (with interrupts enabled), it is plain unnecessary to take the risk.

arch/i386/kernel/time-xen.c +5 -2
@@ -666,6 +666,7 @@ irqreturn_t timer_interrupt(int irq, voi
 	s64 delta, delta_cpu, stolen, blocked;
 	u64 sched_time;
 	unsigned int i, cpu = smp_processor_id();
+	int schedule_clock_was_set_work = 0;
 	struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
 	struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
 
@@ -720,12 +721,14 @@ irqreturn_t timer_interrupt(int irq, voi
 
 	if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
 		update_wallclock();
-		if (keventd_up())
-			schedule_work(&clock_was_set_work);
+		schedule_clock_was_set_work = 1;
 	}
 
 	write_sequnlock(&xtime_lock);
 
+	if (schedule_clock_was_set_work && keventd_up())
+		schedule_work(&clock_was_set_work);
+
 	/*
 	 * Account stolen ticks.
 	 * HACK: Passing NULL to account_steal_time()

From: Zdenek Salvet <[email protected]>
Subject: eliminate nesting of run-queue locks inside xtime_lock

According to Debian bug 591362 this has been causing problems. While no proof was given that the inverse lock order does actually occur anywhere (with interrupts enabled), it is plain unnecessary to take the risk.

arch/i386/kernel/time-xen.c +5 -2
@@ -666,6 +666,7 @@ irqreturn_t timer_interrupt(int irq, voi
 	s64 delta, delta_cpu, stolen, blocked;
 	u64 sched_time;
 	unsigned int i, cpu = smp_processor_id();
+	int schedule_clock_was_set_work = 0;
 	struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
 	struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
 
@@ -720,12 +721,14 @@ irqreturn_t timer_interrupt(int irq, voi
 
 	if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
 		update_wallclock();
-		if (keventd_up())
-			schedule_work(&clock_was_set_work);
+		schedule_clock_was_set_work = 1;
 	}
 
 	write_sequnlock(&xtime_lock);
 
+	if (schedule_clock_was_set_work && keventd_up())
+		schedule_work(&clock_was_set_work);
+
 	/*
 	 * Account stolen ticks.
 	 * HACK: Passing NULL to account_steal_time()

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

Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

From: Zdenek Salvet <[email protected]>

According to Debian bug 591362 this has been causing problems. While no proof was given that the inverse lock order does actually occur anywhere (with interrupts enabled), it is plain unnecessary to take the risk.

I'm right in thinking this is for traditional Xen/Linux kernel only, aren't I?

Quoted 31 lines
arch/i386/kernel/time-xen.c +5 -2
@@ -666,6 +666,7 @@ irqreturn_t timer_interrupt(int irq, voi
 	s64 delta, delta_cpu, stolen, blocked;
 	u64 sched_time;
 	unsigned int i, cpu = smp_processor_id();
+	int schedule_clock_was_set_work = 0;
 	struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
 	struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
 
@@ -720,12 +721,14 @@ irqreturn_t timer_interrupt(int irq, voi
 
 	if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
 		update_wallclock();
-		if (keventd_up())
-			schedule_work(&clock_was_set_work);
+		schedule_clock_was_set_work = 1;
 	}
 
 	write_sequnlock(&xtime_lock);
 
+	if (schedule_clock_was_set_work && keventd_up())
+		schedule_work(&clock_was_set_work);
+
 	/*
 	 * Account stolen ticks.
 	 * HACK: Passing NULL to account_steal_time()
#2 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Jan Beulich

From: Zdenek Salvet <[email protected]>

According to Debian bug 591362 this has been causing problems. While no proof was given that the inverse lock order does actually occur anywhere (with interrupts enabled), it is plain unnecessary to take the risk.

Quoted 4 lines
Quoted 1 line

I'm right in thinking this is for traditional Xen/Linux kernel only, aren't I?

Yes, absolutely.

Jan