Skip to content

Commit ded467d

Browse files
author
Peter Zijlstra
committed
sched, lockdep: Annotate ->pi_lock recursion
There's a valid ->pi_lock recursion issue where the actual PI code tries to wake up the stop task. Make lockdep aware so it doesn't complain about this. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com> Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com> Link: https://lkml.kernel.org/r/20201023102347.406912197@infradead.org
1 parent 95158a8 commit ded467d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎kernel/sched/core.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,7 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
26582658

26592659
void sched_set_stop_task(int cpu, struct task_struct *stop)
26602660
{
2661+
static struct lock_class_key stop_pi_lock;
26612662
struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 };
26622663
struct task_struct *old_stop = cpu_rq(cpu)->stop;
26632664

@@ -2673,6 +2674,20 @@ void sched_set_stop_task(int cpu, struct task_struct *stop)
26732674
sched_setscheduler_nocheck(stop, SCHED_FIFO, &param);
26742675

26752676
stop->sched_class = &stop_sched_class;
2677+
2678+
/*
2679+
* The PI code calls rt_mutex_setprio() with ->pi_lock held to
2680+
* adjust the effective priority of a task. As a result,
2681+
* rt_mutex_setprio() can trigger (RT) balancing operations,
2682+
* which can then trigger wakeups of the stop thread to push
2683+
* around the current task.
2684+
*
2685+
* The stop task itself will never be part of the PI-chain, it
2686+
* never blocks, therefore that ->pi_lock recursion is safe.
2687+
* Tell lockdep about this by placing the stop->pi_lock in its
2688+
* own class.
2689+
*/
2690+
lockdep_set_class(&stop->pi_lock, &stop_pi_lock);
26762691
}
26772692

26782693
cpu_rq(cpu)->stop = stop;

0 commit comments

Comments
 (0)