(资料图片)
2、常见的死锁方式
常见死锁的2种方式:
常见的死锁有以下4种情况:
内核提供了Lockdep
来检测死锁的异常情况。
3、Lockdep 内核配置
4、Lockdep 初探
锁的几个状态:
5、Lockdep 检查规则
单锁状态规则如下:(1)一个软中断不安全的锁类也是硬中断不安全的锁类。
(2)任何一个锁类,不可能同时是硬中断安全的和硬中断不安全的,也不可能同时是软中断安全的和软中断不安全的。也就是说:硬中断安全和硬中断不安全是互斥的,软中断安全和软中断不安全也是互斥的。
多锁依赖规则如下:(1)同一个锁类不能被获取两次,否则可能导致递归死锁(AA死锁)。
(2)不能以不同顺序获取两个锁类,否则导致AB-BA死锁。
(3)不允许在获取硬中断安全的锁类之后获取硬中断不安全的锁类。
(4)不允许在获取软中断安全的锁类之后获取软中断不安全的锁类。
6、输出分析
#ifconfigwlan0up[152.765951][152.767477]============================================[152.772802]WARNING:possiblerecursivelockingdetected[152.778130]4.19.123#4Tainted:GO[152.783021]--------------------------------------------[152.788347]ifconfig/231istryingtoacquirelock:[152.793243]c043f769(pmutex){+.+.},at:phy_RFSerialRead_8723D+0x30/0x168[8723ds]ctimer:152793251832,htime:152765938707,wtime:000000000000[152.807243][152.807243]buttaskisalreadyholdinglock:[152.813093]97637552(pmutex){+.+.},at:netdev_open+0x64/0xb0[8723ds]ctimer:152813101541,htime:151310817588,wtime:000000000000[152.825872][152.825872]otherinfothatmighthelpusdebugthis:[152.832415]Possibleunsafelockingscenario:[152.832415][152.838349]CPU0[152.840810]----[152.843269]lock(pmutex);[152.846082]lock(pmutex);[152.848894][152.848894]***DEADLOCK***[152.848894][152.854831]Maybeduetomissinglocknestingnotation[152.854831][152.861637]2locksheldbyifconfig/231:[152.865659]#0:cdd640ad(rtnl_mutex){+.+.},at:devinet_ioctl+0x118/0x5f8ctimer:152865670624,htime:151310702505,wtime:000000000000[152.877865]#1:97637552(pmutex){+.+.},at:netdev_open+0x64/0xb0[8723ds]ctimer:152877875915,htime:151310817588,wtime:000000000000[152.891057][152.891057]stackbacktrace:[152.895439]CPU:1PID:231Comm:ifconfigTainted:GO4.19.123#4[152.903022]Hardwarename:arobotr8family[152.907245][](unwind_backtrace)from[](show_stack+0x10/0x14)[152.915018][](show_stack)from[](dump_stack+0xa4/0xd8)[152.922268][](dump_stack)from[](__lock_acquire+0x1218/0x129c)[152.930209][](__lock_acquire)from[](lock_acquire+0x150/0x240)[152.938151][](lock_acquire)from[](__mutex_lock+0x7c/0x890)[152.945833][](__mutex_lock)from[](mutex_lock_interruptible_nested+0x18/0x20)[152.955975][](mutex_lock_interruptible_nested)from[](phy_RFSerialRead_8723D+0x30/0x168[8723ds])[152.968687][](phy_RFSerialRead_8723D[8723ds])from[](PHY_QueryRFReg_8723D+0xc/0x24[8723ds])[152.981030][](PHY_QueryRFReg_8723D[8723ds])from[](rtl8723ds_hal_init+0x28c/0x864[8723ds])[152.993294][](rtl8723ds_hal_init[8723ds])from[](rtw_hal_init+0x30/0x144[8723ds])[153.004763][](rtw_hal_init[8723ds])from[](_netdev_open+0x8c/0x290[8723ds])[153.015713][](_netdev_open[8723ds])from[](netdev_open+0x7c/0xb0[8723ds])[153.025646][](netdev_open[8723ds])from[](__dev_open+0x7c/0xc8)[153.033766][](__dev_open)from[](__dev_change_flags+0x148/0x15c)[153.041878][](__dev_change_flags)from[](dev_change_flags+0x18/0x48)[153.050339][](dev_change_flags)from[](devinet_ioctl+0x304/0x5f8)[153.058539][](devinet_ioctl)from[](inet_ioctl+0x278/0x350)[153.066222][](inet_ioctl)from[](sock_ioctl+0x190/0x50c)[153.073647][](sock_ioctl)from[](vfs_ioctl+0x28/0x3c)[153.080808][](vfs_ioctl)from[](do_vfs_ioctl+0x98/0x96c)[153.088229][](do_vfs_ioctl)from[](ksys_ioctl+0x38/0x54)[153.095650][](ksys_ioctl)from[](ret_fast_syscall+0x0/0x28)[153.103321]Exceptionstack(0xc67f7fa8to0xc67f7ff0)[153.108395]7fa0:000a88e2bef753480000000300008914bef75348000a88e2[153.116594]7fc0:000a88e2bef75348000946d000000036bef7550cbef75508bef7570d00000000[153.124788]7fe0:000c72e4bef752e40001b528b6e59166[153.130116]
标签: