Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4f200e

Browse files
fbqPeter Zijlstra
authored and
Peter Zijlstra
committed
lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior
As our chain cache doesn't differ read/write locks, so even we candetect a read-lock/lock-write deadlock in check_noncircular(), we canstill be fooled if a read-lock/lock-read case(which is not a deadlock)comes first.So introduce this test case to test specific to the chain cache behavioron detecting recursive read lock related deadlocks.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-14-boqun.feng@gmail.com
1 parent621c9da commitd4f200e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎lib/locking-selftest.c‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,49 @@ static void rwsem_ABBA1(void)
396396
MU(Y1);// should fail
397397
}
398398

399+
/*
400+
* read_lock(A)
401+
* spin_lock(B)
402+
*spin_lock(B)
403+
*write_lock(A)
404+
*
405+
* This test case is aimed at poking whether the chain cache prevents us from
406+
* detecting a read-lock/lock-write deadlock: if the chain cache doesn't differ
407+
* read/write locks, the following case may happen
408+
*
409+
* { read_lock(A)->lock(B) dependency exists }
410+
*
411+
* P0:
412+
* lock(B);
413+
* read_lock(A);
414+
*
415+
*{ Not a deadlock, B -> A is added in the chain cache }
416+
*
417+
*P1:
418+
*lock(B);
419+
*write_lock(A);
420+
*
421+
*{ B->A found in chain cache, not reported as a deadlock }
422+
*
423+
*/
424+
staticvoidrlock_chaincache_ABBA1(void)
425+
{
426+
RL(X1);
427+
L(Y1);
428+
U(Y1);
429+
RU(X1);
430+
431+
L(Y1);
432+
RL(X1);
433+
RU(X1);
434+
U(Y1);
435+
436+
L(Y1);
437+
WL(X1);
438+
WU(X1);
439+
U(Y1);// should fail
440+
}
441+
399442
/*
400443
* read_lock(A)
401444
* spin_lock(B)
@@ -2062,6 +2105,10 @@ void locking_selftest(void)
20622105
pr_cont(" |");
20632106
dotest(rwsem_ABBA3,FAILURE,LOCKTYPE_RWSEM);
20642107

2108+
print_testname("chain cached mixed R-L/L-W ABBA");
2109+
pr_cont(" |");
2110+
dotest(rlock_chaincache_ABBA1,FAILURE,LOCKTYPE_RWLOCK);
2111+
20652112
printk(" --------------------------------------------------------------------------\n");
20662113

20672114
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp