netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Prevent multiple NAPI instances co-existing in the list
@ 2015-01-08  8:22 Dennis Chen
  2015-01-08 11:15 ` Herbert Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Dennis Chen @ 2015-01-08  8:22 UTC (permalink / raw)
  To: netdev, Herbert Xu, Miller, Eric Dumazet; +Cc: Dennis Chen

Some drivers may clear the NAPI_STATE_SCHED bit upon the state of the
NAPI instance after exhaust the budget in the poll function, which
will open a window for next device interrupt handler to insert a same
instance to the list after calling list_add_tail(&n->poll_list,
repoll) if we don't set this bit.

Signed-off-by: Dennis Chen <kernel.org.gnu@gmail.com>
---
 net/core/dev.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 683d493..b3107ac 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4619,6 +4619,14 @@ static int napi_poll(struct napi_struct *n,
struct list_head *repoll)
                             n->dev ? n->dev->name : "backlog");
                goto out_unlock;
        }
+
+       /* Some drivers may exit the polling mode when exhaust the
+        * budget. Set the NAPI_STATE_SCHED bit to prevent multiple NAPI
+        * instances in the list in case of next device interrupt raised.
+        */
+       if (unlikely(!test_and_set_bit(NAPI_STATE_SCHED, &n->state)))
+               pr_warn_once("%s: exit polling mode after exhaust the budget\n",
+                            n->dev ? n->dev->name : "backlog");

        list_add_tail(&n->poll_list, repoll);

-- 
1.7.9.5

-- 
Den

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-01-09  3:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08  8:22 [PATCH] net: Prevent multiple NAPI instances co-existing in the list Dennis Chen
2015-01-08 11:15 ` Herbert Xu
2015-01-09  2:24   ` Dennis Chen
2015-01-09  2:27     ` Herbert Xu
2015-01-09  2:32       ` Dennis Chen
2015-01-09  2:34         ` Herbert Xu
2015-01-09  2:50           ` Dennis Chen
2015-01-09  3:07           ` Dennis Chen
2015-01-08 13:04 ` Sergei Shtylyov
2015-01-09  2:28   ` Dennis Chen
2015-01-08 14:51 ` Eric Dumazet
2015-01-09  2:26   ` Dennis Chen
2015-01-09  3:12     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).