use of rwlocks safe in network stack?
john.giacomoni at lineratesystems.com
Fri Aug 20 21:45:23 UTC 2010
Can someone help me understand how it is safe to process network packets from within a driver's interrupt context?
It looks to me like the network drivers (bce in particular) violate the rules laid out in locking (9).
In FreeBSD 7.3 the bce driver's RX interrupt can call up into the network stack (bce_intr -> bce_rx_intr -> if_input) which will grab INP_INFO_WLOCK (rw_wlock) when it hits the TCP layer.
pfslowtimo also acquires INP_INFO_LOCK.
Is this safe? locking (9) says that acquiring a rw_wlock is not allowed in interrupt context and rw_wlock can "sleep" via mi_switch in the turnstile code.
Is this a locking order type rule? and if so, is the rule being ignored because network stack is guaranteed to return in a finite amount of time? Or is the bce interrupt a different type of interrupt than referred to in locking (9) ?
More information about the freebsd-hackers