History

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.

Peter Zijlstra committed 6 years ago

Commit ded467d1 parent 95158a81 file · +15 −0Browse files

Unified · Split

kernel/sched/core.c+15−0
@@ -2658,6 +2658,7 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags) · 2657 unmodified lines
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) · 9 unmodified lines
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;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t