login
Header Space

 
 

Re: soft lockup - CPU#1 stuck for 15s! [swapper:0]

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Parag Warudkar <parag.warudkar@...>
Cc: Len Brown <lenb@...>, Arjan van de Ven <arjan@...>, Ingo Molnar <mingo@...>, Pallipadi, Venkatesh <venkatesh.pallipadi@...>, LKML <linux-kernel@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Date: Saturday, December 15, 2007 - 4:10 am

On Fri, 14 Dec 2007, Parag Warudkar wrote:


I have a patch staged for Linus, which fixes a thinko in the broadcast
code. It might be related to your problem. Can you give it a try ?

Thanks,

	tglx

------>

Subject: clockevents: fix reprogramming decision in oneshot broadcast
From: Thomas Gleixner <tglx@linutronix.de>

A previous version of the code did the reprogramming of the broadcast
device in the return from idle code. This was removed, but the logic in
tick_handle_oneshot_broadcast() was kept the same.

When a broadcast interrupt happens we signal the expiry to all CPUs
which have an expired event. If none of the CPUs has an expired event,
which can happen in dyntick mode, then we reprogram the broadcast
device. We do not reprogram otherwise, but this is only correct if all
CPUs, which are in the idle broadcast state have been woken up.

The code ignores, that there might be pending not yet expired events on
other CPUs, which are in the idle broadcast state. So the delivery of
those events can be delayed for quite a time.

Change the tick_handle_oneshot_broadcast() function to check for CPUs,
which are in broadcast state and are not woken up by the current event,
and enforce the rearming of the broadcast device for those CPUs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/time/tick-broadcast.c |   56 ++++++++++++++++---------------------------
 1 file changed, 21 insertions(+), 35 deletions(-)

Index: linux-x86.q/kernel/time/tick-broadcast.c
===================================================================
--- linux-x86.q.orig/kernel/time/tick-broadcast.c
+++ linux-x86.q/kernel/time/tick-broadcast.c
@@ -384,45 +384,19 @@ int tick_resume_broadcast_oneshot(struct
 }
 
 /*
- * Reprogram the broadcast device:
- *
- * Called with tick_broadcast_lock held and interrupts disabled.
- */
-static int tick_broadcast_reprogram(void)
-{
-	ktime_t expires = { .tv64 = KTIME_MAX };
-	struct tick_device *td;
-	int cpu;
-
-	/*
-	 * Find the event which expires next:
-	 */
-	for (cpu = first_cpu(tick_broadcast_oneshot_mask); cpu != NR_CPUS;
-	     cpu = next_cpu(cpu, tick_broadcast_oneshot_mask)) {
-		td = &per_cpu(tick_cpu_device, cpu);
-		if (td->evtdev->next_event.tv64 < expires.tv64)
-			expires = td->evtdev->next_event;
-	}
-
-	if (expires.tv64 == KTIME_MAX)
-		return 0;
-
-	return tick_broadcast_set_event(expires, 0);
-}
-
-/*
  * Handle oneshot mode broadcasting
  */
 static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
 {
 	struct tick_device *td;
 	cpumask_t mask;
-	ktime_t now;
+	ktime_t now, next_event;
 	int cpu;
 
 	spin_lock(&tick_broadcast_lock);
 again:
 	dev->next_event.tv64 = KTIME_MAX;
+	next_event.tv64 = KTIME_MAX;
 	mask = CPU_MASK_NONE;
 	now = ktime_get();
 	/* Find all expired events */
@@ -431,19 +405,31 @@ again:
 		td = &per_cpu(tick_cpu_device, cpu);
 		if (td->evtdev->next_event.tv64 <= now.tv64)
 			cpu_set(cpu, mask);
+		else if (td->evtdev->next_event.tv64 < next_event.tv64)
+			next_event.tv64 = td->evtdev->next_event.tv64;
 	}
 
 	/*
-	 * Wakeup the cpus which have an expired event. The broadcast
-	 * device is reprogrammed in the return from idle code.
+	 * Wakeup the cpus which have an expired event.
+	 */
+	tick_do_broadcast(mask);
+
+	/*
+	 * Two reasons for reprogram:
+	 *
+	 * - The global event did not expire any CPU local
+	 * events. This happens in dyntick mode, as the maximum PIT
+	 * delta is quite small.
+	 *
+	 * - There are pending events on sleeping CPUs which were not
+	 * in the event mask
 	 */
-	if (!tick_do_broadcast(mask)) {
+	if (next_event.tv64 != KTIME_MAX) {
 		/*
-		 * The global event did not expire any CPU local
-		 * events. This happens in dyntick mode, as the
-		 * maximum PIT delta is quite small.
+		 * Rearm the broadcast device. If event expired,
+		 * repeat the above
 		 */
-		if (tick_broadcast_reprogram())
+		if (tick_broadcast_set_event(next_event, 0))
 			goto again;
 	}
 	spin_unlock(&tick_broadcast_lock);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
BUG: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Fri Dec 7, 6:53 pm)
Re: BUG: soft lockup - CPU#1 stuck for 15s! [swapper:0], Andrew Morton, (Fri Dec 7, 7:17 pm)
Re: BUG: soft lockup - CPU#1 stuck for 15s! [swapper:0], Rafael J. Wysocki, (Fri Dec 7, 10:35 pm)
RE: soft lockup - CPU#1 stuck for 15s! [swapper:0], Pallipadi, Venkatesh, (Fri Dec 7, 7:12 pm)
RE: soft lockup - CPU#1 stuck for 15s! [swapper:0], Thomas Gleixner, (Fri Dec 7, 10:56 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 11:10 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 11:36 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Ingo Molnar, (Sat Dec 8, 11:47 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 12:00 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Ingo Molnar, (Sat Dec 8, 3:13 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 3:33 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Ingo Molnar, (Sat Dec 8, 3:42 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 4:08 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Ingo Molnar, (Sat Dec 8, 4:11 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 4:46 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Arjan van de Ven, (Sat Dec 8, 4:51 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 5:04 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sat Dec 8, 7:12 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Sun Dec 9, 5:57 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Thomas Gleixner, (Mon Dec 10, 1:49 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Tue Dec 11, 12:49 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Len Brown, (Fri Dec 14, 7:17 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Fri Dec 14, 8:51 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Thomas Gleixner, (Sat Dec 15, 4:10 am)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Arjan van de Ven, (Sun Dec 9, 6:30 pm)
Re: soft lockup - CPU#1 stuck for 15s! [swapper:0], Parag Warudkar, (Fri Dec 7, 7:31 pm)
speck-geostationary