diff options
author | David S. Miller <davem@davemloft.net> | 2008-03-27 20:42:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-27 20:42:50 -0400 |
commit | 50fd4407b8bfbde7c1a0bfe4f24de7df37164342 (patch) | |
tree | 57a9f05b130903fb2c6c12412352928bb24dc3a7 /include/linux | |
parent | 8eeee8b152ae6bbe181518efaf62ba8e9c613693 (diff) |
[NET]: Use local_irq_{save,restore}() in napi_complete().
Based upon a lockdep report.
Since ->poll() can be invoked from netpoll with interrupts
disabled, we must not unconditionally enable interrupts
in napi_complete().
Instead we must use local_irq_{save,restore}().
Noticed by Peter Zijlstra:
<irqs disabled>
netpoll_poll()
poll_napi()
spin_trylock(&napi->poll_lock)
poll_one_napi()
napi->poll() := sky2_poll()
napi_complete()
local_irq_disable()
local_irq_enable() <--- *BUG*
<irq>
irq_exit()
do_softirq()
net_rx_action()
spin_lock(&napi->poll_lock) <--- Deadlock!
Because we still hold the lock....
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/netdevice.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a2f003239c85..fae6a7ececdb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -383,9 +383,11 @@ static inline void __napi_complete(struct napi_struct *n) | |||
383 | 383 | ||
384 | static inline void napi_complete(struct napi_struct *n) | 384 | static inline void napi_complete(struct napi_struct *n) |
385 | { | 385 | { |
386 | local_irq_disable(); | 386 | unsigned long flags; |
387 | |||
388 | local_irq_save(flags); | ||
387 | __napi_complete(n); | 389 | __napi_complete(n); |
388 | local_irq_enable(); | 390 | local_irq_restore(flags); |
389 | } | 391 | } |
390 | 392 | ||
391 | /** | 393 | /** |