summaryrefslogtreecommitdiffstats
path: root/lib/locking-selftest.c
diff options
context:
space:
mode:
authorBoqun Feng <boqun.feng@gmail.com>2020-08-07 15:42:33 +0800
committerPeter Zijlstra <peterz@infradead.org>2020-08-26 12:42:06 +0200
commitf611e8cf98ec908b9c2c0da6064a660fc6022487 (patch)
tree4cd8ee925a3af4711d7a5060f7939e1b49f30325 /lib/locking-selftest.c
parentd4f200e579e96051f1f081f795820787826eb234 (diff)
downloadlinux-f611e8cf98ec908b9c2c0da6064a660fc6022487.tar.gz
linux-f611e8cf98ec908b9c2c0da6064a660fc6022487.tar.bz2
linux-f611e8cf98ec908b9c2c0da6064a660fc6022487.zip
lockdep: Take read/write status in consideration when generate chainkey
Currently, the chainkey of a lock chain is a hash sum of the class_idx of all the held locks, the read/write status are not taken in to consideration while generating the chainkey. This could result into a problem, if we have: P1() { read_lock(B); lock(A); } P2() { lock(A); read_lock(B); } P3() { lock(A); write_lock(B); } , and P1(), P2(), P3() run one by one. And when running P2(), lockdep detects such a lock chain A -> B is not a deadlock, then it's added in the chain cache, and then when running P3(), even if it's a deadlock, we could miss it because of the hit of chain cache. This could be confirmed by self testcase "chain cached mixed R-L/L-W ". To resolve this, we use concept "hlock_id" to generate the chainkey, the hlock_id is a tuple (hlock->class_idx, hlock->read), which fits in a u16 type. With this, the chainkeys are different is the lock sequences have the same locks but different read/write status. Besides, since we use "hlock_id" to generate chainkeys, the chain_hlocks array now store the "hlock_id"s rather than lock_class indexes. 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-15-boqun.feng@gmail.com
Diffstat (limited to 'lib/locking-selftest.c')
0 files changed, 0 insertions, 0 deletions