Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.25-rc7-git3 /kernel/sched.c

Filename:/kernel/sched.c
Lines Added:43
Lines Deleted:0
Also changed in: (Previous) 2.6.25-rc7-git2  2.6.25-rc7-git1  2.6.25-rc7  2.6.25-rc6-git8  2.6.25-rc6-git7  2.6.25-rc6-git6 
(Following) 2.6.25-rc7-git4  2.6.25-rc7-git5  2.6.25-rc7-git6  2.6.25-rc8  2.6.25-rc9  2.6.25 

Location
[  2.6.25-rc7-git3
  [  kernel
     o  sched.c

Patch

diff --git a/kernel/sched.c b/kernel/sched.c
index 28c73f0..8dcdec6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1052,6 +1052,49 @@ static void resched_cpu(int cpu)
    resched_task(cpu_curr(cpu));
    spin_unlock_irqrestore(&rq->lock, flags);
 }
+
+#ifdef CONFIG_NO_HZ
+/*
+ * When add_timer_on() enqueues a timer into the timer wheel of an
+ * idle CPU then this timer might expire before the next timer event
+ * which is scheduled to wake up that CPU. In case of a completely
+ * idle system the next event might even be infinite time into the
+ * future. wake_up_idle_cpu() ensures that the CPU is woken up and
+ * leaves the inner idle loop so the newly added timer is taken into
+ * account when the CPU goes back to idle and evaluates the timer
+ * wheel for the next timer event.
+ */
+void wake_up_idle_cpu(int cpu)
+{
+   struct rq *rq = cpu_rq(cpu);
+
+   if (cpu == smp_processor_id())
+      return;
+
+   /*
+    * This is safe, as this function is called with the timer
+    * wheel base lock of (cpu) held. When the CPU is on the way
+    * to idle and has not yet set rq->curr to idle then it will
+    * be serialized on the timer wheel base lock and take the new
+    * timer into account automatically.
+    */
+   if (rq->curr != rq->idle)
+      return;
+
+   /*
+    * We can set TIF_RESCHED on the idle task of the other CPU
+    * lockless. The worst case is that the other CPU runs the
+    * idle task through an additional NOOP schedule()
+    */
+   set_tsk_thread_flag(rq->idle, TIF_NEED_RESCHED);
+
+   /* NEED_RESCHED must be visible before we test polling */
+   smp_mb();
+   if (!tsk_is_polling(rq->idle))
+      smp_send_reschedule(cpu);
+}
+#endif
+
 #else
 static void __resched_task(struct task_struct *p, int tif_bit)
 {


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.