sched: Fix potential near-infinite distribute_cfs_runtime() loop
authorBen Segall <bsegall@google.com>
Fri, 20 Jun 2014 22:21:20 +0000 (15:21 -0700)
committerIngo Molnar <mingo@kernel.org>
Sat, 5 Jul 2014 09:17:29 +0000 (11:17 +0200)
commitc06f04c70489b9deea3212af8375e2f0c2f0b184
tree4f2191c49ce53726392f8a4aa983c44c4e13d96e
parent541b82644d72c1ef4a0587515a619712c1c19bd3
sched: Fix potential near-infinite distribute_cfs_runtime() loop

distribute_cfs_runtime() intentionally only hands out enough runtime to
bring each cfs_rq to 1 ns of runtime, expecting the cfs_rqs to then take
the runtime they need only once they actually get to run. However, if
they get to run sufficiently quickly, the period timer is still in
distribute_cfs_runtime() and no runtime is available, causing them to
throttle. Then distribute has to handle them again, and this can go on
until distribute has handed out all of the runtime 1ns at a time, which
takes far too long.

Instead allow access to the same runtime that distribute is handing out,
accepting that corner cases with very low quota may be able to spend the
entire cfs_b->runtime during distribute_cfs_runtime, meaning that the
runtime directly handed out by distribute_cfs_runtime was over quota. In
addition, if a cfs_rq does manage to throttle like this, make sure the
existing distribute_cfs_runtime no longer loops over it again.

Signed-off-by: Ben Segall <bsegall@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140620222120.13814.21652.stgit@sword-of-the-dawn.mtv.corp.google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/fair.c