Skip to content

Commit

Permalink
sched: Fix lockup by limiting load-balance retries on lock-break
Browse files Browse the repository at this point in the history
Eric and David reported dead machines and traced it to commit
a195f00 ("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 <[email protected]>
Tested-by: Eric Dumazet <[email protected]>
Reported-by: David Ahern <[email protected]>
[ logic cleanup as suggested by Eric ]
Signed-off-by: Peter Zijlstra <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Suresh Siddha <[email protected]>
Link: http://lkml.kernel.org/r/1326297936.2442.157.camel@twins
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jan 11, 2012
1 parent 6db9dc1 commit bced76a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -3130,8 +3130,10 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
}

#define LBF_ALL_PINNED 0x01
#define LBF_NEED_BREAK 0x02
#define LBF_ABORT 0x04
#define LBF_NEED_BREAK 0x02 /* clears into HAD_BREAK */
#define LBF_HAD_BREAK 0x04
#define LBF_HAD_BREAKS 0x0C /* count HAD_BREAKs overflows into ABORT */
#define LBF_ABORT 0x10

/*
* can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
Expand Down Expand Up @@ -4508,7 +4510,9 @@ static int load_balance(int this_cpu, struct rq *this_rq,
goto out_balanced;

if (lb_flags & LBF_NEED_BREAK) {
lb_flags &= ~LBF_NEED_BREAK;
lb_flags += LBF_HAD_BREAK - LBF_NEED_BREAK;
if (lb_flags & LBF_ABORT)
goto out_balanced;
goto redo;
}

Expand Down

0 comments on commit bced76a

Please sign in to comment.