From: Wei Wang <weiwan@google.com>
To: "David S . Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Cc: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Paolo Abeni <pabeni@redhat.com>, Felix Fietkau <nbd@nbd.name>,
Wei Wang <weiwan@google.com>
Subject: [PATCH net-next 3/5] net: extract napi poll functionality to __napi_poll()
Date: Wed, 30 Sep 2020 12:21:38 -0700 [thread overview]
Message-ID: <20200930192140.4192859-4-weiwan@google.com> (raw)
In-Reply-To: <20200930192140.4192859-1-weiwan@google.com>
From: Felix Fietkau <nbd@nbd.name>
This commit introduces a new function __napi_poll() which does the main
logic of the existing napi_poll() function, and will be called by other
functions in later commits.
This idea and implementation is done by Felix Fietkau <nbd@nbd.name> and
is proposed as part of the patch to move napi work to work_queue
context.
This commit by itself is a code restructure.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Wei Wang <weiwan@google.com>
---
net/core/dev.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 259cd7f3434f..c82522262ca8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6783,15 +6783,10 @@ void __netif_napi_del(struct napi_struct *napi)
}
EXPORT_SYMBOL(__netif_napi_del);
-static int napi_poll(struct napi_struct *n, struct list_head *repoll)
+static int __napi_poll(struct napi_struct *n, bool *repoll)
{
- void *have;
int work, weight;
- list_del_init(&n->poll_list);
-
- have = netpoll_poll_lock(n);
-
weight = n->weight;
/* This NAPI_STATE_SCHED test is for avoiding a race
@@ -6811,7 +6806,7 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
n->poll, work, weight);
if (likely(work < weight))
- goto out_unlock;
+ return work;
/* Drivers must not modify the NAPI state if they
* consume the entire weight. In such cases this code
@@ -6820,7 +6815,7 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
*/
if (unlikely(napi_disable_pending(n))) {
napi_complete(n);
- goto out_unlock;
+ return work;
}
if (n->gro_bitmask) {
@@ -6832,6 +6827,26 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
gro_normal_list(n);
+ *repoll = true;
+
+ return work;
+}
+
+static int napi_poll(struct napi_struct *n, struct list_head *repoll)
+{
+ bool do_repoll = false;
+ void *have;
+ int work;
+
+ list_del_init(&n->poll_list);
+
+ have = netpoll_poll_lock(n);
+
+ work = __napi_poll(n, &do_repoll);
+
+ if (!do_repoll)
+ goto out_unlock;
+
/* Some drivers may have called napi_schedule
* prior to exhausting their budget.
*/
--
2.28.0.709.gb0816b6eb0-goog
next prev parent reply other threads:[~2020-09-30 19:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 19:21 [PATCH net-next 0/5] implement kthread based napi poll Wei Wang
2020-09-30 19:21 ` [PATCH net-next 1/5] net: implement threaded-able napi poll loop support Wei Wang
2020-09-30 19:21 ` [PATCH net-next 2/5] net: add sysfs attribute to control napi threaded mode Wei Wang
2020-09-30 19:21 ` Wei Wang [this message]
2020-09-30 19:21 ` [PATCH net-next 4/5] net: modify kthread handler to use __napi_poll() Wei Wang
2020-09-30 19:21 ` [PATCH net-next 5/5] net: improve napi threaded config Wei Wang
2020-10-01 10:01 ` Felix Fietkau
2020-10-01 17:01 ` Wei Wang
2020-10-01 17:11 ` Felix Fietkau
2020-10-01 18:03 ` Eric Dumazet
2020-10-01 18:37 ` Felix Fietkau
2020-10-01 19:24 ` Wei Wang
2020-10-01 20:48 ` Felix Fietkau
2020-10-01 22:42 ` Wei Wang
2020-09-30 20:08 ` [PATCH net-next 0/5] implement kthread based napi poll Jakub Kicinski
2020-10-01 7:52 ` Eric Dumazet
2020-10-01 20:26 ` Jakub Kicinski
2020-10-01 22:12 ` Wei Wang
2020-10-01 23:46 ` Jakub Kicinski
2020-10-02 1:44 ` Wei Wang
2020-10-02 22:53 ` Jakub Kicinski
2020-10-02 7:56 ` Eric Dumazet
2020-10-02 22:49 ` Jakub Kicinski
2020-10-02 23:00 ` David Miller
2020-10-02 23:15 ` Alexei Starovoitov
2020-10-03 3:54 ` Eric Dumazet
2020-10-03 4:17 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200930192140.4192859-4-weiwan@google.com \
--to=weiwan@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hannes@stressinduktion.org \
--cc=kuba@kernel.org \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).