lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240922150746.185408-1-wangtaowt166@163.com>
Date: Sun, 22 Sep 2024 23:07:46 +0800
From: tao <wangtaowt166@....com>
To: davem@...emloft.net
Cc: edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	jiri@...nulli.us,
	bigeasy@...utronix.de,
	lorenzo@...nel.org,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	tao <wangtaowt166@....com>
Subject: [PATCH] netdev: support netdev_budget for napi thread poll

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@....com>
---
 net/core/dev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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();
 	}
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ