lkml.org 
[lkml]   [2022]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: possible deadlock in __ata_sff_interrupt
On Thu, Dec 15, 2022 at 7:41 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> CPU1: ptrace(2)
> ptrace_check_attach()
> read_lock(&tasklist_lock);
>
> CPU2: setpgid(2)
> write_lock_irq(&tasklist_lock);
> spins
>
> CPU1: takes an interrupt that would call kill_fasync(). grep and the
> first instance of kill_fasync() is in hpet_interrupt() - it's not
> something exotic. IRQs disabled on CPU2 won't stop it.
> kill_fasync(..., SIGIO, ...)
> kill_fasync_rcu()
> read_lock_irqsave(&fa->fa_lock, flags);
> send_sigio()
> read_lock_irqsave(&fown->lock, flags);
> read_lock(&tasklist_lock);
>
> ... and CPU1 spins as well.

Nope. See kernel/locking/qrwlock.c:

/*
* Readers come here when they cannot get the lock without waiting
*/
if (unlikely(in_interrupt())) {
/*
* Readers in interrupt context will get the lock immediately
* if the writer is just waiting (not holding the lock yet),
* so spin with ACQUIRE semantics until the lock is available
* without waiting in the queue.
*/
atomic_cond_read_acquire(&lock->cnts, !(VAL & _QW_LOCKED));
return;
}

and that's the new "civilized" reader unfairness.

The traditional rwlock was unconditionally unfair to writers, to the
point that there were starvation issues because new readers would
always get the lock.

Linus

\
 
 \ /
  Last update: 2022-12-16 12:27    [W:1.117 / U:0.912 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site