void sched_set_stop_task(int cpu, struct task_struct *stop)
 {
+       static struct lock_class_key stop_pi_lock;
        struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 };
        struct task_struct *old_stop = cpu_rq(cpu)->stop;
 
                sched_setscheduler_nocheck(stop, SCHED_FIFO, ¶m);
 
                stop->sched_class = &stop_sched_class;
+
+               /*
+                * The PI code calls rt_mutex_setprio() with ->pi_lock held to
+                * adjust the effective priority of a task. As a result,
+                * rt_mutex_setprio() can trigger (RT) balancing operations,
+                * which can then trigger wakeups of the stop thread to push
+                * around the current task.
+                *
+                * The stop task itself will never be part of the PI-chain, it
+                * never blocks, therefore that ->pi_lock recursion is safe.
+                * Tell lockdep about this by placing the stop->pi_lock in its
+                * own class.
+                */
+               lockdep_set_class(&stop->pi_lock, &stop_pi_lock);
        }
 
        cpu_rq(cpu)->stop = stop;