blob: c5003de25a5af0c3972d1b3fff4d044838d05dba [file] [log] [blame]
From efbbf2f27cdbe06e184d352044469f94452b6001 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 3 Jul 2009 08:30:06 -0500
Subject: [PATCH] sched: Prevent boosting of idle task on -rt
commit 4ee888c3c41c562c6d575011cc4696bcddc2f956 in tip.
Idle task boosting is a nono in general. There is one exception, when
NOHZ is active:
The idle task calls get_next_timer_interrupt() and holds the timer
wheel base->lock on the CPU and another CPU wants to access the timer
(probably to cancel it). We can safely ignore the boosting request, as
the idle CPU runs this code with interrupts disabled and will complete
the lock protected section without being interrupted. So there is no
real need to boost.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/kernel/sched.c b/kernel/sched.c
index e96ac22..49feb1f 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6297,6 +6297,25 @@ void task_setprio(struct task_struct *p, int prio)
BUG_ON(prio < 0 || prio > MAX_PRIO);
rq = task_rq_lock(p, &flags);
+
+ /*
+ * Idle task boosting is a nono in general. There is one
+ * exception, when NOHZ is active:
+ *
+ * The idle task calls get_next_timer_interrupt() and holds
+ * the timer wheel base->lock on the CPU and another CPU wants
+ * to access the timer (probably to cancel it). We can safely
+ * ignore the boosting request, as the idle CPU runs this code
+ * with interrupts disabled and will complete the lock
+ * protected section without being interrupted. So there is no
+ * real need to boost.
+ */
+ if (unlikely(p == rq->idle)) {
+ WARN_ON(p != rq->curr);
+ WARN_ON(p->pi_blocked_on);
+ goto out_unlock;
+ }
+
update_rq_clock(rq);
oldprio = p->prio;
@@ -6324,6 +6343,7 @@ void task_setprio(struct task_struct *p, int prio)
check_class_changed(rq, p, prev_class, oldprio, running);
}
+out_unlock:
task_rq_unlock(rq, &flags);
}
--
1.7.1.1