LOCKDEP

简介

验证程序操作的基本对象是锁的类型。

一类锁是一组在锁规则上逻辑上相同的锁,即使锁可能具有多个(可能是数万个)实例化。 例如,inode结构中的锁是一个类,而每个inode具有该锁类的自己的实例化。

验证器跟踪锁类的“状态”,并跟踪不同锁类之间的依赖关系。 验证器保持状态和依赖关系正确的滚动证明。

锁实例化不同,锁类本身永远不会消失:在启动后首次使用锁类时,它将被注册,并且该锁类的所有后续使用都将附加到该锁类上

使用介绍

在 Kernel hacking -> Lock Debuging 中开启 LOCK_DEP 测试,(注意不要开启 LOCK_STAT)

img

运行后,会启动自动测试

[    0.000424] Lock dependency validator: Copyright (c) 2006 Red Har
[    0.000443] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.000460] ... MAX_LOCK_DEPTH:          48
[    0.000476] ... MAX_LOCKDEP_KEYS:        8192
[    0.000492] ... CLASSHASH_SIZE:          4096
[    0.000508] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.000524] ... MAX_LOCKDEP_CHAINS:      65536
[    0.000540] ... CHAINHASH_SIZE:          32768
[    0.000556]  memory used by lock dependency info: 6301 kB
[    0.000572]  memory used for stack traces: 4224 kB
[    0.000588]  per task-struct memory footprint: 1920 bytes
[    0.000604] ------------------------
[    0.000620] | Locking API testsuite:
[    0.000636] -----------------------------------------------------
[    0.000651]                                  | spin |wlock |rloc|
[    0.000667]   ---------------------------------------------------
[    0.000698]                      A-A deadlock:  ok  |  ok  |  ok|
[    0.009065]                  A-B-B-A deadlock:  ok  |  ok  |  ok|
[    0.018270]              A-B-B-C-C-A deadlock:  ok  |  ok  |  ok|
[    0.028441]              A-B-C-A-B-C deadlock:  ok  |  ok  |  ok|
[    0.038546]          A-B-B-C-C-D-D-A deadlock:  ok  |  ok  |  ok|
[    0.049592]          A-B-C-D-B-D-D-A deadlock:  ok  |  ok  |  ok|
[    0.060594]          A-B-C-D-B-C-D-A deadlock:  ok  |  ok  |  ok|
[    0.071571]                     double unlock:  ok  |  ok  |  ok|
[    0.079825]                   initialize held:  ok  |  ok  |  ok|
[    0.087588]   ---------------------------------------------------
[    0.087606]               recursive read-lock:             |  ok|
[    0.090094]            recursive read-lock #2:             |  ok|
[    0.092472]             mixed read-write-lock:             |  ok|
[    0.094807]             mixed write-read-lock:             |  ok|
[    0.097203]   mixed read-lock/lock-write ABBA:             |  ok|
[    0.099780]    mixed read-lock/lock-read ABBA:             |FAIL|
[    0.102444]  mixed write-lock/lock-write ABBA:             |  ok|
[    0.105050]   ---------------------------------------------------
[    0.105079]      hard-irqs-on + irq-safe-A/12:  ok  |  ok  |  ok|
[    0.108638]      soft-irqs-on + irq-safe-A/12:  ok  |  ok  |  ok|
[    0.112183]      hard-irqs-on + irq-safe-A/21:  ok  |  ok  |  ok|
[    0.115749]      soft-irqs-on + irq-safe-A/21:  ok  |  ok  |  ok|
[    0.119282]        sirq-safe-A => hirqs-on/12:  ok  |  ok  |  ok|
[    0.122826]        sirq-safe-A => hirqs-on/21:  ok  |  ok  |  ok|
[    0.126384]          hard-safe-A + irqs-on/12:  ok  |  ok  |  ok|
[    0.129957]          soft-safe-A + irqs-on/12:  ok  |  ok  |  ok|
[    0.133488]          hard-safe-A + irqs-on/21:  ok  |  ok  |  ok|
[    0.137056]          soft-safe-A + irqs-on/21:  ok  |  ok  |  ok|
[    0.140635]     hard-safe-A + unsafe-B #1/123:  ok  |  ok  |  ok|
[    0.144589]     soft-safe-A + unsafe-B #1/123:  ok  |  ok  |  ok|
[    0.148522]     hard-safe-A + unsafe-B #1/132:  ok  |  ok  |  ok|
[    0.152483]     soft-safe-A + unsafe-B #1/132:  ok  |  ok  |  ok|
[    0.156465]     hard-safe-A + unsafe-B #1/213:  ok  |  ok  |  ok|
[    0.160438]     soft-safe-A + unsafe-B #1/213:  ok  |  ok  |  ok|
[    0.164415]     hard-safe-A + unsafe-B #1/231:  ok  |  ok  |  ok|
[    0.168325]     soft-safe-A + unsafe-B #1/231:  ok  |  ok  |  ok|

results matching ""

    No results matching ""