NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/54617: deadlock between sysmon and onewire drivers

>Number:         54617
>Category:       kern
>Synopsis:       deadlock between sysmon and onewire drivers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 14 12:00:00 +0000 2019
>Originator:     Andrew Doran
>Release:        8.1
Andrew Doran
NetBSD steamy.local 8.1_STABLE NetBSD 8.1_STABLE (GENERIC) #1: Sat Oct  5 23:56:59 IST 2019  ad@steamy.local:/local/home/ad/src-81/src/sys/arch/amd64/compile/GENERIC amd64
Processing an envstat(1) invocation.  sme_global_mtx is acquired, and then owtemp_refresh() called to read the sensor data.  In turn this attempts to acquire the onewire rwlock, which is already held:

crash> t/a fffffe80795274e0
trace: pid 6734 lid 1 at 0xffff800043f66b10
sleepq_block() at sleepq_block+0x97
turnstile_block() at turnstile_block+0x24f
rw_vector_enter() at rw_vector_enter+0x120
owtemp_refresh() at owtemp_refresh+0x22
sysmon_envsys_refresh_sensor() at sysmon_envsys_refresh_sensor+0x80
sme_update_dictionary() at sme_update_dictionary+0xca
sysmonioctl_envsys() at sysmonioctl_envsys+0x28e
vn_ioctl() at vn_ioctl+0xa6
sys_ioctl() at sys_ioctl+0x11a
syscall() at syscall+0x1ec
--- syscall (number 54) ---
crash> ps/w | grep 6734
6734     1          envstat   netbsd   43 tstile       fffffe807decfe10
crash> x/Lx fffffe807decfe10
fffffe807decfe10:       fffffe807d004ba7
crash> ps | grep fffffe807d004ba
0       74 3   0       200   fffffe807d004ba0           onewire0 tstile

Concurrently, onewire_thread() thinks the device is gone.  This kthread holds the onewire rwlock, and during the detach attempts to acquire sme_global_mtx:

crash> t/a fffffe807d004ba0
trace: pid 0 lid 74 at 0xffff800043f0ae00
sleepq_block() at sleepq_block+0x97
turnstile_block() at turnstile_block+0x24f
mutex_vector_enter() at mutex_vector_enter+0x34a
sysmon_envsys_unregister() at sysmon_envsys_unregister+0x16
owtemp_detach() at owtemp_detach+0x15
config_detach() at config_detach+0xa1
onewire_thread() at onewire_thread+0x283

Drive some devices via owtemp & call envstat regularly.

None offered.  I suspect this is a pattern repeated elsewhere.

Home | Main Index | Thread Index | Old Index