[RFC PATCH 14/15] nohz_task: Clear nohz task attribute on exit()

From: Frederic Weisbecker
Date: Mon Dec 20 2010 - 10:25:39 EST


Clear the nohz task attribute when a task exits, clear the cpu
mask and restart the tick if necessary.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Anton Blanchard <anton@xxxxxxxxxxx>
Cc: Tim Pepper <lnxninja@xxxxxxxxxxxxxxxxxx>
---
include/linux/tick.h | 2 ++
kernel/exit.c | 3 +++
kernel/time/tick-sched.c | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/linux/tick.h b/include/linux/tick.h
index a704bb7..37af961 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -137,6 +137,7 @@ extern void tick_nohz_task_enter_kernel(void);
extern void tick_nohz_task_exit_kernel(void);
extern void tick_nohz_task_enter_exception(struct pt_regs *regs);
extern void tick_nohz_task_exit_exception(struct pt_regs *regs);
+extern void tick_nohz_task_clear(void);
extern int tick_nohz_task_mode(void);

#else /* !NO_HZ_TASK */
@@ -144,6 +145,7 @@ static inline void tick_nohz_task_enter_kernel(void) { }
static inline void tick_nohz_task_exit_kernel(void) { }
static inline void tick_nohz_task_enter_exception(struct pt_regs *regs) { }
static inline void tick_nohz_task_exit_exception(struct pt_regs *regs) { }
+static inline void tick_nohz_task_clear(void) { }
static inline int tick_nohz_task_mode(void) { return 0; }
#endif /* !NO_HZ_TASK */

diff --git a/kernel/exit.c b/kernel/exit.c
index 676149a..250d832 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -51,6 +51,7 @@
#include <trace/events/sched.h>
#include <linux/hw_breakpoint.h>
#include <linux/oom.h>
+#include <linux/tick.h>

#include <asm/uaccess.h>
#include <asm/unistd.h>
@@ -1013,6 +1014,8 @@ NORET_TYPE void do_exit(long code)
*/
perf_event_exit_task(tsk);

+ tick_nohz_task_clear();
+
exit_notify(tsk, group_dead);
#ifdef CONFIG_NUMA
task_lock(tsk);
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 9a4aa39..06379eb 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -720,6 +720,26 @@ void tick_check_idle(int cpu)
}

#ifdef CONFIG_NO_HZ_TASK
+void tick_nohz_task_clear(void)
+{
+ int cpu = raw_smp_processor_id();
+
+ if (!test_thread_flag(TIF_NOHZ))
+ return;
+
+ set_cpu_has_nohz_task(cpu, 0);
+ clear_tsk_thread_flag(current, TIF_NOHZ);
+
+ local_irq_disable();
+
+ if (__get_cpu_var(task_nohz_mode))
+ tick_nohz_restart_sched_tick();
+
+ __get_cpu_var(task_nohz_mode) = 0;
+
+ local_irq_enable();
+}
+
DEFINE_PER_CPU(int, nohz_task_ext_qs);

void tick_nohz_task_exit_kernel(void)
--
1.7.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/