sched: Fix lockup by limiting load-balance retries on lock-break

Eric and David reported dead machines and traced it to commit
a195f004 ("sched: Fix load-balance lock-breaking"), it turns out
there's still a scenario where we can end up re-trying forever.

Since there is no strict forward progress guarantee in the
load-balance iteration we can get stuck re-retrying the same
task-set over and over.

Creating a forward progress guarantee with the existing
structure is somewhat non-trivial, for now simply terminate the
retry loop after a few tries.

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Tested-by: Eric Dumazet <eric.dumazet@gmail.com>
Reported-by: David Ahern <dsahern@gmail.com>
[ logic cleanup as suggested by Eric ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1326297936.2442.157.camel@twins
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Peter Zijlstra and committed by Ingo Molnar bced76ae 6db9dc15

Changed files
+7 -3
kernel
sched
+7 -3
kernel/sched/fair.c
··· 3130 3130 } 3131 3131 3132 3132 #define LBF_ALL_PINNED 0x01 3133 - #define LBF_NEED_BREAK 0x02 3134 - #define LBF_ABORT 0x04 3133 + #define LBF_NEED_BREAK 0x02 /* clears into HAD_BREAK */ 3134 + #define LBF_HAD_BREAK 0x04 3135 + #define LBF_HAD_BREAKS 0x0C /* count HAD_BREAKs overflows into ABORT */ 3136 + #define LBF_ABORT 0x10 3135 3137 3136 3138 /* 3137 3139 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu? ··· 4510 4508 goto out_balanced; 4511 4509 4512 4510 if (lb_flags & LBF_NEED_BREAK) { 4513 - lb_flags &= ~LBF_NEED_BREAK; 4511 + lb_flags += LBF_HAD_BREAK - LBF_NEED_BREAK; 4512 + if (lb_flags & LBF_ABORT) 4513 + goto out_balanced; 4514 4514 goto redo; 4515 4515 } 4516 4516