login
Header Space

 
 

Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Gabriel C <crazy@...>
Cc: Gabriel C <nix.or.die@...>, Rafael J. Wysocki <rjw@...>, LKML <linux-kernel@...>, Adrian Bunk <bunk@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>, Natalie Protasevich <protasnb@...>, <andi-bz@...>, Ingo Molnar <mingo@...>
Date: Saturday, March 22, 2008 - 5:55 pm

On Sat, 22 Mar 2008, Thomas Gleixner wrote:

Gabriel,

I'm happy to rack your nerves some more.

After discussing the issue with Peter and Ingo the following solution
seems to be the one which is the least intrusive. 

Can you please give it a test ride ?

Thanks,

	tglx
---
 include/linux/sched.h |    6 ++++++
 kernel/sched.c        |   42 ++++++++++++++++++++++++++++++++++++++++++
 kernel/timer.c        |   10 +++++++++-
 3 files changed, 57 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -1541,6 +1541,12 @@ static inline void idle_task_exit(void) 
 
 extern void sched_idle_next(void);
 
+#ifdef CONFIG_NO_HZ
+extern void wake_up_idle_cpu(int cpu);
+#else
+static inline void wake_up_idle_cpu(int cpu) { }
+#endif
+
 #ifdef CONFIG_SCHED_DEBUG
 extern unsigned int sysctl_sched_latency;
 extern unsigned int sysctl_sched_min_granularity;
Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -848,6 +848,48 @@ static inline void resched_task(struct t
 	__resched_task(p, TIF_NEED_RESCHED);
 }
 
+#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 newle 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
+
 #ifdef CONFIG_SCHED_HRTICK
 /*
  * Use HR-timers to deliver accurate preemption points.
Index: linux-2.6/kernel/timer.c
===================================================================
--- linux-2.6.orig/kernel/timer.c
+++ linux-2.6/kernel/timer.c
@@ -451,10 +451,18 @@ void add_timer_on(struct timer_list *tim
 	spin_lock_irqsave(&base->lock, flags);
 	timer_set_base(timer, base);
 	internal_add_timer(base, timer);
+	/*
+	 * Check whether the other CPU is idle and needs to be
+	 * triggered to reevaluate the timer wheel when nohz is
+	 * active. We are protected against the other CPU fiddling
+	 * with the timer by holding the timer base lock. This also
+	 * makes sure that a CPU on the way to idle can not evaluate
+	 * the timer wheel.
+	 */
+	wake_up_idle_cpu(cpu);
 	spin_unlock_irqrestore(&base->lock, flags);
 }
 
-
 /**
  * mod_timer - modify a timer's timeout
  * @timer: the timer to be modified
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.25-rc5-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sun Mar 16, 7:18 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Christian Kujau, (Sun Mar 23, 5:17 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sun Mar 23, 5:29 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Christian Kujau, (Sun Mar 23, 3:01 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sun Mar 23, 3:06 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Mon Mar 17, 5:36 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Mon Mar 17, 12:17 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Fri Mar 21, 12:26 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Fri Mar 21, 2:49 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Fri Mar 21, 5:15 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Fri Mar 21, 6:09 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Sat Mar 22, 7:21 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Andi Kleen, (Sat Mar 22, 10:25 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Sat Mar 22, 10:41 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Sat Mar 22, 10:30 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Sat Mar 22, 12:32 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Sat Mar 22, 5:55 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Mon Mar 24, 6:24 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Tue Mar 25, 4:06 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Thomas Gleixner, (Wed Mar 26, 10:51 am)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Linus Torvalds, (Sun Mar 16, 7:33 pm)
Re: 2.6.25-rc5-git6: Reported regressions from 2.6.24, Rafael J. Wysocki, (Sun Mar 16, 7:38 pm)
speck-geostationary