[Devel] [PATCH vz8] kernel/sched/fair: Fix 'releasing a pinned lock'

Kirill Tkhai ktkhai at virtuozzo.com
Mon Oct 5 16:05:18 MSK 2020


On 05.10.2020 15:36, Andrey Ryabinin wrote:
> Lockdep complains that after rq_repin_lock() the lock wasn't unpinned
> before rq->lock release.
> 
> ------------[ cut here ]------------
> releasing a pinned lock
> WARNING: CPU: 0 PID: 24 at kernel/locking/lockdep.c:4271 lock_release+0x939/0xee0
> Call Trace:
>  _raw_spin_unlock+0x1c/0x30
>  load_balance+0x1472/0x2e30
>  pick_next_task_fair+0x62c/0x2300
>  __schedule+0x481/0x1600
>  schedule+0xbf/0x240
>  worker_thread+0x1d5/0xb50
>  kthread+0x30e/0x3d0
>  ret_from_fork+0x3a/0x50
> 
> Add rq_unpin_lock(); call to fix this. Also for consistency use 'busiest'
> instead of 'env.src_rq' which is the same.
> 
> https://jira.sw.ru/browse/PSBM-120800
> Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>

> ---
>  kernel/sched/fair.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fc87dee4fd0e..23a2f2452474 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9178,9 +9178,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
>  			env.loop = 0;
>  			local_irq_save(rf.flags);
>  			double_rq_lock(env.dst_rq, busiest);
> -			rq_repin_lock(env.src_rq, &rf);
> +			rq_repin_lock(busiest, &rf);
>  			update_rq_clock(env.dst_rq);
>  			cur_ld_moved = ld_moved = move_task_groups(&env);
> +			rq_unpin_lock(busiest, &rf);
>  			double_rq_unlock(env.dst_rq, busiest);
>  			local_irq_restore(rf.flags);
>                  }
> 



More information about the Devel mailing list