[PATCH 15/32] nohz/cpuset: Restart tick when switching to idle task

Frederic Weisbecker
2011-08-15T15:57:19Z

Ideally if we are in adaptive nohz mode and we switch to the
the idle task, we shouldn't restart the tick since it's going
to stop the tick soon anyway.

That optimization requires some minor tweaks here and there
though, lets handle that later.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Blanchard <anton@au1.ibm.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Pepper <lnxninja@linux.vnet.ibm.com>
---
kernel/sched.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 353a66f..9b6b8eb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2477,6 +2477,18 @@ void cpuset_update_nohz(void)
if (!cpuset_nohz_can_stop_tick())
cpuset_nohz_restart_tick();
}
+
+static void cpuset_nohz_task_switch(struct task_struct *next)
+{
+ int cpu = smp_processor_id();
+
+ if (tick_nohz_adaptive_mode() && next == idle_task(cpu))
+ cpuset_nohz_restart_tick();
+}
+#else
+static void cpuset_nohz_task_switch(struct task_struct *next)
+{
+}
#endif

static void
@@ -3023,6 +3035,7 @@ static inline void
prepare_task_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
{
+ cpuset_nohz_task_switch(next);
sched_info_switch(prev, next);
perf_event_task_sched_out(prev, next);
fire_sched_out_preempt_notifiers(prev, next);
--
1.7.5.4