summaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2015-04-15 11:41:57 +0200
committerThomas Gleixner <tglx@linutronix.de>2015-04-22 17:06:53 +0200
commit77a4d1a1b9a122ca1fa3507bd30aec1520d7a8a4 (patch)
treed4912f0a6379207bf160b5666d5ecc20d70412ab /kernel/sched/core.c
parent5de2755c8c8b3a6b8414870e2c284914a2b42e4d (diff)
downloadblackbird-op-linux-77a4d1a1b9a122ca1fa3507bd30aec1520d7a8a4.tar.gz
blackbird-op-linux-77a4d1a1b9a122ca1fa3507bd30aec1520d7a8a4.zip
sched: Cleanup bandwidth timers
Roman reported a 3 cpu lockup scenario involving __start_cfs_bandwidth(). The more I look at that code the more I'm convinced its crack, that entire __start_cfs_bandwidth() thing is brain melting, we don't need to cancel a timer before starting it, *hrtimer_start*() will happily remove the timer for you if its still enqueued. Removing that, removes a big part of the problem, no more ugly cancel loop to get stuck in. So now, if I understand things right, the entire reason you have this cfs_b->lock guarded ->timer_active nonsense is to make sure we don't accidentally lose the timer. It appears to me that it should be possible to guarantee that same by unconditionally (re)starting the timer when !queued. Because regardless what hrtimer::function will return, if we beat it to (re)enqueue the timer, it doesn't matter. Now, because hrtimers don't come with any serialization guarantees we must ensure both handler and (re)start loop serialize their access to the hrtimer to avoid both trying to forward the timer at the same time. Update the rt bandwidth timer to match. This effectively reverts: 09dc4ab03936 ("sched/fair: Fix tg_set_cfs_bandwidth() deadlock on rq->lock"). Reported-by: Roman Gushchin <klamm@yandex-team.ru> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Ben Segall <bsegall@google.com> Cc: Paul Turner <pjt@google.com> Link: http://lkml.kernel.org/r/20150415095011.804589208@infradead.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3026678113e7..d8a6196465d5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -92,10 +92,13 @@
void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period)
{
- if (hrtimer_active(period_timer))
- return;
+ /*
+ * Do not forward the expiration time of active timers;
+ * we do not want to loose an overrun.
+ */
+ if (!hrtimer_active(period_timer))
+ hrtimer_forward_now(period_timer, period);
- hrtimer_forward_now(period_timer, period);
hrtimer_start_expires(period_timer, HRTIMER_MODE_ABS_PINNED);
}
@@ -8113,10 +8116,8 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)
__refill_cfs_bandwidth_runtime(cfs_b);
/* restart the period timer (if active) to handle new period expiry */
- if (runtime_enabled && cfs_b->timer_active) {
- /* force a reprogram */
- __start_cfs_bandwidth(cfs_b, true);
- }
+ if (runtime_enabled)
+ start_cfs_bandwidth(cfs_b);
raw_spin_unlock_irq(&cfs_b->lock);
for_each_online_cpu(i) {
OpenPOWER on IntegriCloud