Skip to content

Commit 39f17c7

Browse files
oleg-nesterovakpm00
authored andcommitted
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/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Mateusz Guzik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f23e76a commit 39f17c7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/linux/sched/task.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ static inline struct vm_struct *task_stack_vm_area(const struct task_struct *t)
210210
* pins the final release of task.io_context. Also protects ->cpuset and
211211
* ->cgroup.subsys[]. And ->vfork_done. And ->sysvshm.shm_clist.
212212
*
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.
216215
*/
217216
static inline void task_lock(struct task_struct *p)
218217
{

0 commit comments

Comments
 (0)