[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+U0gVh+TyEUJ+qmg+FE=UhvvQywfNxcouCyv1sutZ3fav5FAw@mail.gmail.com>
Date: Thu, 8 Jan 2015 16:22:54 +0800
From: Dennis Chen <kernel.org.gnu@...il.com>
To: netdev <netdev@...r.kernel.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Miller <davem@...emloft.net>,
Eric Dumazet <eric.dumazet@...il.com>
Cc: Dennis Chen <kernel.org.gnu@...il.com>
Subject: [PATCH] net: Prevent multiple NAPI instances co-existing in the list
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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists