locking/selftest: Add test cases for queued_read_lock()
authorBoqun Feng <boqun.feng@gmail.com>
Fri, 7 Aug 2020 07:42:37 +0000 (15:42 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 26 Aug 2020 10:42:07 +0000 (12:42 +0200)
commitad56450db86413ff911eb527b5a49e04a4345e61
treefed91c9cc78759489711e694c92b7e27c79ae12b
parent108dc42ed3507fe06214d51ab15fca7771df8bbd
locking/selftest: Add test cases for queued_read_lock()

Add two self test cases for the following case:

P0: P1: P2:

<in irq handler>
spin_lock_irq(&slock) read_lock(&rwlock)
write_lock_irq(&rwlock)
read_lock(&rwlock) spin_lock(&slock)

, which is a deadlock, as the read_lock() on P0 cannot get the lock
because of the fairness.

P0: P1: P2:

<in irq handler>
spin_lock(&slock) read_lock(&rwlock)
write_lock(&rwlock)
read_lock(&rwlock) spin_lock_irq(&slock)

, which is not a deadlock, as the read_lock() on P0 can get the lock
because it could use the unfair fastpass.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200807074238.1632519-19-boqun.feng@gmail.com
lib/locking-selftest.c