diff mbox series

netdev: support netdev_budget for napi thread poll

Message ID 20240922150746.185408-1-wangtaowt166@163.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series netdev: support netdev_budget for napi thread poll | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 21 this patch: 21
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 79 this patch: 79
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-24--03-00 (tests: 762)

Commit Message

tao Sept. 22, 2024, 3:07 p.m. UTC
For napi thread poll, we expect the net.core.netdev_budget to be available.

In the loop, poll as many packets as possible to netdev_budget

Signed-off-by: tao <wangtaowt166@163.com>
---
 net/core/dev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Eric Dumazet Sept. 22, 2024, 3:13 p.m. UTC | #1
On Sun, Sep 22, 2024 at 5:08 PM tao <wangtaowt166@163.com> wrote:
>
> For napi thread poll, we expect the net.core.netdev_budget to be available.
>
> In the loop, poll as many packets as possible to netdev_budget
>

We do not 'expect' net.core.netdev_budget to be available, we have
better cond_resched() calls.

Please provide reasoning, and keep in mind net-next is currently closed.
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 1e740faf9e78..104a17642842 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6876,6 +6876,7 @@  static void napi_threaded_poll_loop(struct napi_struct *napi)
 	struct bpf_net_context __bpf_net_ctx, *bpf_net_ctx;
 	struct softnet_data *sd;
 	unsigned long last_qs = jiffies;
+	int budget = READ_ONCE(net_hotdata.netdev_budget);
 
 	for (;;) {
 		bool repoll = false;
@@ -6888,7 +6889,7 @@  static void napi_threaded_poll_loop(struct napi_struct *napi)
 		sd->in_napi_threaded_poll = true;
 
 		have = netpoll_poll_lock(napi);
-		__napi_poll(napi, &repoll);
+		budget -= __napi_poll(napi, &repoll);
 		netpoll_poll_unlock(have);
 
 		sd->in_napi_threaded_poll = false;
@@ -6905,6 +6906,9 @@  static void napi_threaded_poll_loop(struct napi_struct *napi)
 		if (!repoll)
 			break;
 
+		if (budget > 0)
+			continue;
+
 		rcu_softirq_qs_periodic(last_qs);
 		cond_resched();
 	}