use of rwlocks safe in network stack?

Julian Elischer julian at elischer.org
Sat Aug 21 00:30:15 UTC 2010


On 8/20/10 2:15 PM, John Giacomoni wrote:
> 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).

The trick is that most of the 'interrupt' handlers in the system are 
not really interrupt handlers directly, but rather threads that are 
kicked into life when a 'stub' interrupt handler kicks them.

The stub is system supplied unless the driver specifically supplies 
one (called a "FAST" interrupt handler) in which case THAT is a real 
interrupt handler and must only use spinlocks.

I hope that helps..

I'm sure there is a man page for it in chapter 9 somewhere.
  (looks)
ah yes

man ithread should be a good start.


>
> 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) ?
>
> Thanks,
>
> John Giacomoni
>
>
>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"



More information about the freebsd-hackers mailing list