aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-10-30 00:28:47 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-30 01:37:28 -0400
commit0a7606c121d58c1831805262c5b764e181429e7d (patch)
tree4ba68e147c569c83dfedc3b45edf88ce21cde001 /net/core/dev.c
parentb0a713e9e6091b30d0e615d2be88017a57f37c76 (diff)
[NET]: Fix race between poll_napi() and net_rx_action()
netpoll_poll_lock() synchronizes the ->poll() invocation code paths, but once we have the lock we have to make sure that NAPI_STATE_SCHED is still set. Otherwise we get: cpu 0 cpu 1 net_rx_action() poll_napi() netpoll_poll_lock() ... spin on ->poll_lock ->poll() netif_rx_complete netpoll_poll_unlock() acquire ->poll_lock() ->poll() netif_rx_complete() CRASH Based upon a bug report from Tina Yang. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 853c8b575f1d..02e7d8377c4a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2172,7 +2172,15 @@ static void net_rx_action(struct softirq_action *h)
2172 2172
2173 weight = n->weight; 2173 weight = n->weight;
2174 2174
2175 work = n->poll(n, weight); 2175 /* This NAPI_STATE_SCHED test is for avoiding a race
2176 * with netpoll's poll_napi(). Only the entity which
2177 * obtains the lock and sees NAPI_STATE_SCHED set will
2178 * actually make the ->poll() call. Therefore we avoid
2179 * accidently calling ->poll() when NAPI is not scheduled.
2180 */
2181 work = 0;
2182 if (test_bit(NAPI_STATE_SCHED, &n->state))
2183 work = n->poll(n, weight);
2176 2184
2177 WARN_ON_ONCE(work > weight); 2185 WARN_ON_ONCE(work > weight);
2178 2186