在linux内核中查找锁定统计信息

时间:2015-09-07 17:11:55

标签: linux linux-kernel

我最近研究了Linux锁定机制,并希望看到锁定和等待时间。

所以我通过CONFIG_LOCK_STAT打开.config文件中的make menuconfig标志,重新编译内核后运行命令:

# less /proc/lock_stat

我收到以下消息:

*WARNING* lock debugging disabled!! - possibly due to a lockdep warning.

我不知道为什么,因为我已经打开了内核hack->lock会话中的所有标记。

P.S。我使用的环境:内核3.12.6(uname -a)。

更新:dmesg与__debug_locks_off()dump_stack()

[    0.000000]  [<ffffffff817516a2>] _raw_write_lock+0x72/0x80
[    0.000000]  [<ffffffff81392718>] ? irqsafe4_soft_wlock_213+0x98/0xf0
[    0.000000]  [<ffffffff81392718>] irqsafe4_soft_wlock_213+0x98/0xf0
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399cd6>] locking_selftest+0x1286/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/231:### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  0000000000000002 ffffffff81c01c38 ffffffff81747f7c ffffffff81c15c98
[    0.000000]  ffffffff81c01c48 ffffffff81383d27 ffffffff81c01d60 ffffffff810d9d1e
[    0.000000]  ffffffff81c01ff8 ffffffff81c00000 ffffffff81c01fe8 ffffffff824d2d58
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810d9d1e>] check_usage+0x10e/0x550
[    0.000000]  [<ffffffff810170f4>] ? dump_trace+0x194/0x2f0
[    0.000000]  [<ffffffff810d6a54>] ? __bfs+0x24/0x240
[    0.000000]  [<ffffffff810da1af>] check_irq_usage+0x4f/0xc0
[    0.000000]  [<ffffffff810dd1ae>] __lock_acquire+0x1bce/0x2190
[    0.000000]  [<ffffffff817511e7>] ? _raw_spin_unlock_irqrestore+0x67/0x70
[    0.000000]  [<ffffffff810c13b6>] ? vprintk_emit+0x1d6/0x630
[    0.000000]  [<ffffffff810de882>] lock_acquire+0xb2/0x160
[    0.000000]  [<ffffffff8138b936>] ? irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff8138b870>] ? irqsafe4_hard_rlock_231+0x110/0x110
[    0.000000]  [<ffffffff81750e96>] _raw_spin_lock+0x46/0x80
[    0.000000]  [<ffffffff8138b936>] ? irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff8138b936>] irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d22>] locking_selftest+0x12d2/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000] ### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  ffffffff81c15580 ffffffff81c01e78 ffffffff81747f7c ffffffff81cab258
[    0.000000]  ffffffff81c01e88 ffffffff81383d27 ffffffff81c01ed8 ffffffff810df539
[    0.000000]  0000000000000082 ffffffff8138b936 0000000000000092 ffffffff81cab258
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810df539>] lock_acquired+0x2f9/0x4d0
[    0.000000]  [<ffffffff8138b936>] ? irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff8138b870>] ? irqsafe4_hard_rlock_231+0x110/0x110
[    0.000000]  [<ffffffff81750ec2>] _raw_spin_lock+0x72/0x80
[    0.000000]  [<ffffffff8138b936>] ? irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff8138b936>] irqsafe4_hard_spin_231+0xc6/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d22>] locking_selftest+0x12d2/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  0000000000000002 ffffffff81c01c38 ffffffff81747f7c ffffffff81c15c98
[    0.000000]  ffffffff81c01c48 ffffffff81383d27 ffffffff81c01d60 ffffffff810d9d1e
[    0.000000]  ffffffff81c01ff8 ffffffff81c00000 ffffffff81c01fe8 ffffffff824d3138
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810d9d1e>] check_usage+0x10e/0x550
[    0.000000]  [<ffffffff810170f4>] ? dump_trace+0x194/0x2f0
[    0.000000]  [<ffffffff810d6a54>] ? __bfs+0x24/0x240
[    0.000000]  [<ffffffff810da1af>] check_irq_usage+0x4f/0xc0
[    0.000000]  [<ffffffff810dd1ae>] __lock_acquire+0x1bce/0x2190
[    0.000000]  [<ffffffff810d80e8>] ? lockdep_init_map+0x68/0x6d0
[    0.000000]  [<ffffffff810de882>] lock_acquire+0xb2/0x160
[    0.000000]  [<ffffffff81392636>] ? irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff81392570>] ? irqsafe4_soft_wlock_231+0xf0/0xf0
[    0.000000]  [<ffffffff81751676>] _raw_write_lock+0x46/0x80
[    0.000000]  [<ffffffff81392636>] ? irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff81392636>] irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d35>] locking_selftest+0x12e5/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000] ### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  ffffffff81c15580 ffffffff81c01e78 ffffffff81747f7c ffffffff81cab058
[    0.000000]  ffffffff81c01e88 ffffffff81383d27 ffffffff81c01ed8 ffffffff810df539
[    0.000000]  0000000000000082 ffffffff81392636 0000000000000092 ffffffff81cab058
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810df539>] lock_acquired+0x2f9/0x4d0
[    0.000000]  [<ffffffff81392636>] ? irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff81392570>] ? irqsafe4_soft_wlock_231+0xf0/0xf0
[    0.000000]  [<ffffffff817516a2>] _raw_write_lock+0x72/0x80
[    0.000000]  [<ffffffff81392636>] ? irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff81392636>] irqsafe4_hard_wlock_231+0xc6/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d35>] locking_selftest+0x12e5/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/231:### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  0000000000000006 ffffffff81c01c38 ffffffff81747f7c ffffffff81c15c98
[    0.000000]  ffffffff81c01c48 ffffffff81383d27 ffffffff81c01d60 ffffffff810d9d1e
[    0.000000]  ffffffff81c01cd8 0000000081c00000 ffffffff81c01fe8 0000000000000001
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810d9d1e>] check_usage+0x10e/0x550
[    0.000000]  [<ffffffff810d9ac2>] ? check_usage_backwards+0x72/0x1c0
[    0.000000]  [<ffffffff810d6a54>] ? __bfs+0x24/0x240
[    0.000000]  [<ffffffff810da1af>] check_irq_usage+0x4f/0xc0
[    0.000000]  [<ffffffff810dd1cd>] __lock_acquire+0x1bed/0x2190
[    0.000000]  [<ffffffff817511e7>] ? _raw_spin_unlock_irqrestore+0x67/0x70
[    0.000000]  [<ffffffff810c13b6>] ? vprintk_emit+0x1d6/0x630
[    0.000000]  [<ffffffff810de882>] lock_acquire+0xb2/0x160
[    0.000000]  [<ffffffff8138d6f8>] ? irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff8138d650>] ? irqsafe4_soft_rlock_231+0xf0/0xf0
[    0.000000]  [<ffffffff81750e96>] _raw_spin_lock+0x46/0x80
[    0.000000]  [<ffffffff8138d6f8>] ? irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff8138d6f8>] irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d81>] locking_selftest+0x1331/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000] ### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  ffffffff81c15580 ffffffff81c01e78 ffffffff81747f7c ffffffff81cab258
[    0.000000]  ffffffff81c01e88 ffffffff81383d27 ffffffff81c01ed8 ffffffff810df539
[    0.000000]  0000000000000282 ffffffff8138d6f8 0000000000000292 ffffffff81cab258
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810df539>] lock_acquired+0x2f9/0x4d0
[    0.000000]  [<ffffffff8138d6f8>] ? irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff8138d650>] ? irqsafe4_soft_rlock_231+0xf0/0xf0
[    0.000000]  [<ffffffff81750ec2>] _raw_spin_lock+0x72/0x80
[    0.000000]  [<ffffffff8138d6f8>] ? irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff8138d6f8>] irqsafe4_soft_spin_231+0xa8/0xf0
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d81>] locking_selftest+0x1331/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  0000000000000006 ffffffff81c01c38 ffffffff81747f7c ffffffff81c15c98
[    0.000000]  ffffffff81c01c48 ffffffff81383d27 ffffffff81c01d60 ffffffff810d9d1e
[    0.000000]  ffffffff81c01cd8 0000000081c00000 ffffffff81c01fe8 0000000000000001
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810d9d1e>] check_usage+0x10e/0x550
[    0.000000]  [<ffffffff810d9ac2>] ? check_usage_backwards+0x72/0x1c0
[    0.000000]  [<ffffffff810d6a54>] ? __bfs+0x24/0x240
[    0.000000]  [<ffffffff810da1af>] check_irq_usage+0x4f/0xc0
[    0.000000]  [<ffffffff810dd1cd>] __lock_acquire+0x1bed/0x2190
[    0.000000]  [<ffffffff810d80e8>] ? lockdep_init_map+0x68/0x6d0
[    0.000000]  [<ffffffff810de882>] lock_acquire+0xb2/0x160
[    0.000000]  [<ffffffff81392528>] ? irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff81392480>] ? irqsafe4_hard_wlock_312+0x110/0x110
[    0.000000]  [<ffffffff81751676>] _raw_write_lock+0x46/0x80
[    0.000000]  [<ffffffff81392528>] ? irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff81392528>] irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d94>] locking_selftest+0x1344/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000] ### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  ffffffff81c15580 ffffffff81c01e78 ffffffff81747f7c ffffffff81cab058
[    0.000000]  ffffffff81c01e88 ffffffff81383d27 ffffffff81c01ed8 ffffffff810df539
[    0.000000]  0000000000000282 ffffffff81392528 0000000000000292 ffffffff81cab058
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810df539>] lock_acquired+0x2f9/0x4d0
[    0.000000]  [<ffffffff81392528>] ? irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff81392480>] ? irqsafe4_hard_wlock_312+0x110/0x110
[    0.000000]  [<ffffffff817516a2>] _raw_write_lock+0x72/0x80
[    0.000000]  [<ffffffff81392528>] ? irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff81392528>] irqsafe4_soft_wlock_231+0xa8/0xf0
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399d94>] locking_selftest+0x1344/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/312:### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  0000000000000000 ffffffff81c01cb0 ffffffff81747f7c ffffffff81c15c98
[    0.000000]  ffffffff81c01cc0 ffffffff81383d27 ffffffff81c01d50 ffffffff810d9adf
[    0.000000]  0000000000000000 ffffffff8288dec0 ffffffff824d43a8 0000000081c01d60
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810d9adf>] check_usage_backwards+0x8f/0x1c0
[    0.000000]  [<ffffffff810da9c2>] mark_lock+0x412/0x820
[    0.000000]  [<ffffffff810d9a50>] ? check_usage_forwards+0x1c0/0x1c0
[    0.000000]  [<ffffffff810dbf68>] __lock_acquire+0x988/0x2190
[    0.000000]  [<ffffffff817511e7>] ? _raw_spin_unlock_irqrestore+0x67/0x70
[    0.000000]  [<ffffffff810c13b6>] ? vprintk_emit+0x1d6/0x630
[    0.000000]  [<ffffffff810de882>] lock_acquire+0xb2/0x160
[    0.000000]  [<ffffffff8138b72e>] ? irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff8138b650>] ? irqsafe4_hard_rlock_312+0x110/0x110
[    0.000000]  [<ffffffff81750e96>] _raw_spin_lock+0x46/0x80
[    0.000000]  [<ffffffff8138b72e>] ? irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff8138b72e>] irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399de0>] locking_selftest+0x1390/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] x86_64_start_reservations+0x2a/0x2c
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000] ### __debug_locks_off called!
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.6 #13
[    0.000000] Hardware name: Sony Corporation VGN-Z25TN_B/VAIO, BIOS R2140M3 08/26/2008
[    0.000000]  ffffffff81c15580 ffffffff81c01e78 ffffffff81747f7c ffffffff81cab258
[    0.000000]  ffffffff81c01e88 ffffffff81383d27 ffffffff81c01ed8 ffffffff810df595
[    0.000000]  0000000000000282 ffffffff8138b72e 0000000000000292 ffffffff81cab258
[    0.000000] Call Trace:
[    0.000000]  [<ffffffff81747f7c>] dump_stack+0x54/0x74
[    0.000000]  [<ffffffff81383d27>] debug_locks_off+0x17/0x50
[    0.000000]  [<ffffffff810df595>] lock_acquired+0x355/0x4d0
[    0.000000]  [<ffffffff8138b72e>] ? irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff8138b650>] ? irqsafe4_hard_rlock_312+0x110/0x110
[    0.000000]  [<ffffffff81750ec2>] _raw_spin_lock+0x72/0x80
[    0.000000]  [<ffffffff8138b72e>] ? irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff8138b72e>] irqsafe4_hard_spin_312+0xde/0x110
[    0.000000]  [<ffffffff817481f5>] dotest+0x43/0x5a7
[    0.000000]  [<ffffffff81399de0>] locking_selftest+0x1390/0x2100
[    0.000000]  [<ffffffff81f1aca9>] start_kernel+0x2d2/0x427
[    0.000000]  [<ffffffff81f1a120>] ? early_idt_handlers+0x120/0x120
[    0.000000]  [<ffffffff81f1a4c7>] 
[    0.000000]  [<ffffffff81f1a5d6>] x86_64_start_kernel+0x10d/0x11c
[    0.000000]   ok  |
[    0.000000] -------------------------------------------------------
[    0.000000] Good, all 253 testcases passed! |
[    0.000000] ---------------------------------
[    0.000000] hpet clockevent registered

2 个答案:

答案 0 :(得分:2)

启用锁定统计信息

首先要确保启用锁定统计信息收集。来自Documentation/locking/lockstat.txt

  
      
  • CONFIGURATION
  •   
     

通过CONFIG_LOCK_STAT启用锁定统计信息。

     
      
  • USAGE
  •   
     

启用统计信息收集:

# echo 1 >/proc/sys/kernel/lock_stat
     

禁用统计信息收集:

# echo 0 >/proc/sys/kernel/lock_stat
     

查看当前的锁定统计信息:

     

(行号不是实际输出的一部分,为了清楚起见,在解释中        下面)

# less /proc/lock_stat

因此,请务必先启用锁定统计信息的收集。

检查内核日志中的lockdep警告

现在,让我们来看一下打印警告信息的代码:

kernel/locking/lockdep_proc.c : seq_header()

if (unlikely(!debug_locks))
    seq_printf(m, "*WARNING* lock debugging disabled!! - possibly due to a lockdep warning\n");

这个debug_locks变量被debug_locks_off()函数设置为0(禁用),而{strong}批次可以从批次调用。我们来看看定义此变量的位置:

lib/debug_locks.c

/*
 * We want to turn all lock-debugging facilities on/off at once,
 * via a global flag. The reason is that once a single bug has been
 * detected and reported, there might be cascade of followup bugs
 * that would just muddy the log. So we report the first one and
 * shut up after that.
 */
int debug_locks = 1;
EXPORT_SYMBOL_GPL(debug_locks);

对该变量的评论解释了为什么会看到该警告。

因此,请检查您的内核日志(通过dmesg命令),了解lockdep机制发现的实际错误。您可能会找到一个,这将解释为什么禁用锁定调试。

更新

关于此消息:

  

[0.084000] SMP替代方案:lockdep:修复替代方案

它似乎与您的实际问题无关。此消息正在通过下一个代码打印:

arch/x86/kernel/alternative.c : alternatives_enable_smp()

#ifdef CONFIG_LOCKDEP
   /*
    * Older binutils section handling bug prevented
    * alternatives-replacement from working reliably.
    *
    * If this still occurs then you should see a hang
    * or crash shortly after this line:
    */
   pr_info("lockdep: fixing up alternatives\n");
#endif

此代码已过时且过时,并且已通过此提交在较新的内核版本中删除:

lockdep, x86/alternatives: Drop ancient lockdep fixup message

所以我认为这是导致无法收集锁定统计信息的其他因素。虽然很难说清楚到底是什么。我唯一能想到的就是修改内核,以便你可以看到导致禁用锁定调试的原因,重建内核并查看内核日志以找出锁定调试禁用的地方。

因此,如果您对此有所了解,请按以下步骤修改__debug_locks_off()函数:

static inline int __debug_locks_off(void)
{
    /* ---- Add this code ---- */
    pr_err("### __debug_locks_off() called!\n");
    dump_stack();
    /* ----------------------- */

    return xchg(&debug_locks, 0);
}

此外,在该文件的顶部添加#include <linux/printk.h>行,以防万一。

然后重建内核,运行它并提供整个dmesg输出。它应该足以说明它被禁用的位置。

更新2

正如我从您提供的回溯中看到的,所有dump_stack()次调用(您添加到__debug_locks_off()函数中) - 他们从locking_selftest()函数调用,而这只是一些函数单元测试程序。我们来看看它:locking_selftest()。这里需要注意的是这段代码:

} else {
    printk("-------------------------------------------------------\n");
    printk("Good, all %3d testcases passed! |\n",
        testcase_successes);
    printk("---------------------------------\n");
    debug_locks = 1;
}

因此,您可以看到,在您的情况下,您在debug_locks的末尾启用了locking_selftest()变量(&#34; on&#34;)。考虑到您提供的所有邮件实际上是从locking_selftest()触发的帐户我可以说这些邮件无法导致您的问题(已禁用debug_locks变量)。

所以你仍然需要弄清楚,在哪里和为什么(在你的情况下)这个debug_locks变量被禁用。让我们从这开始:请与我们分享完整的dmesg输出(您可以使用一些pastebin服务,只需添加您的问题的链接或新评论)。您可能会忽略__debug_locks_off()输出中的dmesg调用,这实际上是相关的(不是从自我测试例程中调用的)。

答案 1 :(得分:0)

您可以设置CONFIG_PROVE_RCU_REPEATEDLY=y,这意味着“请勿在首次展示时停用PROVE_RCU