Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/task.h: fix the wrong comment on task_lock() nesting with tasklist_lock

The ancient comment above task_lock() states that it can be nested outside
of read_lock(&tasklist_lock), but this is no longer true:

CPU_0 CPU_1 CPU_2

task_lock() read_lock(tasklist)
write_lock_irq(tasklist)
read_lock(tasklist) task_lock()

Unless CPU_0 calls read_lock() in IRQ context, queued_read_lock_slowpath()
won't get the lock immediately, it will spin waiting for the pending
writer on CPU_2, resulting in a deadlock.

Link: https://lkml.kernel.org/r/20250914110908.GA18769@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Andrew Morton
39f17c70 f23e76a3

+2 -3
+2 -3
include/linux/sched/task.h
··· 210 210 * pins the final release of task.io_context. Also protects ->cpuset and 211 211 * ->cgroup.subsys[]. And ->vfork_done. And ->sysvshm.shm_clist. 212 212 * 213 - * Nests both inside and outside of read_lock(&tasklist_lock). 214 - * It must not be nested with write_lock_irq(&tasklist_lock), 215 - * neither inside nor outside. 213 + * Nests inside of read_lock(&tasklist_lock). It must not be nested with 214 + * write_lock_irq(&tasklist_lock), neither inside nor outside. 216 215 */ 217 216 static inline void task_lock(struct task_struct *p) 218 217 {