sched: avoid false lockdep splat in put_task_struct()
authorWander Lairson Costa <wander@redhat.com>
Wed, 14 Jun 2023 12:23:22 +0000 (09:23 -0300)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 13 Jul 2023 13:21:48 +0000 (15:21 +0200)
commit893cdaaa3977be6afb3a7f756fbfd7be83f68d8c
treea97d1a636213462cff5f969f3db05cbe34833b16
parentd243b34459cea30cfe5f3a9b2feb44e7daff9938
sched: avoid false lockdep splat in put_task_struct()

In put_task_struct(), a spin_lock is indirectly acquired under the kernel
stock. When running the kernel in real-time (RT) configuration, the
operation is dispatched to a preemptible context call to ensure
guaranteed preemption. However, if PROVE_RAW_LOCK_NESTING is enabled
and __put_task_struct() is called while holding a raw_spinlock, lockdep
incorrectly reports an "Invalid lock context" in the stock kernel.

This false splat occurs because lockdep is unaware of the different
route taken under RT. To address this issue, override the inner wait
type to prevent the false lockdep splat.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230614122323.37957-3-wander@redhat.com
include/linux/sched/task.h