[RFC PATCH 13/15] sched: Protect nohz task cpu affinity

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


Don't allow to change a nohz task cpu affinity as we want them
to be bound to a single CPU and we want this affinity not to
change.

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>
---
kernel/sched.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 4412493..bd0a41f 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5712,6 +5712,13 @@ again:
goto out;
}

+ /* Nohz tasks must keep their affinity */
+ if (test_tsk_thread_flag(p, TIF_NOHZ) &&
+ !cpumask_equal(&p->cpus_allowed, new_mask)) {
+ ret = -EBUSY;
+ goto out;
+ }
+
if (p->sched_class->set_cpus_allowed)
p->sched_class->set_cpus_allowed(p, new_mask);
else {
--
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/