Re: [RFC,v2 1/3] sched: set loop_max after rq lock is taken
From: Peter Zijlstra
Date: Thu Feb 09 2017 - 08:35:56 EST
On Wed, Feb 08, 2017 at 09:43:27AM +0100, Uladzislau Rezki wrote:
> From: Uladzislau 2 Rezki <uladzislau2.rezki@xxxxxxxxxxxxxx>
>
> While doing a load balance there is a race in setting
> loop_max variable since nr_running can be changed causing
> incorect iteration loops.
>
> As a result we may skip some candidates or check the same
> tasks again.
When doing the actual migration we'll drop this lock again and
nr_running can change again.
This cannot be done perfectly, all of load-balancing is riddled with
races like this, nobody cares.