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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250617002236.30557-2-kerneljasonxing@gmail.com>
Date: Tue, 17 Jun 2025 08:22:35 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	bjorn@...nel.org,
	magnus.karlsson@...el.com,
	maciej.fijalkowski@...el.com,
	jonathan.lemon@...il.com,
	sdf@...ichev.me,
	ast@...nel.org,
	daniel@...earbox.net,
	hawk@...nel.org,
	john.fastabend@...il.com
Cc: bpf@...r.kernel.org,
	netdev@...r.kernel.org,
	Jason Xing <kernelxing@...cent.com>
Subject: [PATCH net-next 1/2] net: xsk: make MAX_PER_SOCKET_BUDGET tunable

From: Jason Xing <kernelxing@...cent.com>

Make MAX_PER_SOCKET_BUDGET tunable and let users decide how many descs
they expect to peek at one time.

Signed-off-by: Jason Xing <kernelxing@...cent.com>
---
 include/net/hotdata.h      | 1 +
 net/core/hotdata.c         | 3 ++-
 net/core/sysctl_net_core.c | 7 +++++++
 net/xdp/xsk.c              | 6 ++++--
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/net/hotdata.h b/include/net/hotdata.h
index fda94b2647ff..2df1e8175a85 100644
--- a/include/net/hotdata.h
+++ b/include/net/hotdata.h
@@ -40,6 +40,7 @@ struct net_hotdata {
 	int			sysctl_max_skb_frags;
 	int			sysctl_skb_defer_max;
 	int			sysctl_mem_pcpu_rsv;
+	int			sysctl_xsk_max_per_socket_budget;
 };
 
 #define inet_ehash_secret	net_hotdata.tcp_protocol.secret
diff --git a/net/core/hotdata.c b/net/core/hotdata.c
index 0bc893d5f07b..5131714eee63 100644
--- a/net/core/hotdata.c
+++ b/net/core/hotdata.c
@@ -19,6 +19,7 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
 	.dev_rx_weight = 64,
 	.sysctl_max_skb_frags = MAX_SKB_FRAGS,
 	.sysctl_skb_defer_max = 64,
-	.sysctl_mem_pcpu_rsv = SK_MEMORY_PCPU_RESERVE
+	.sysctl_mem_pcpu_rsv = SK_MEMORY_PCPU_RESERVE,
+	.sysctl_xsk_max_per_socket_budget = 32
 };
 EXPORT_SYMBOL(net_hotdata);
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 5dbb2c6f371d..9f9946b7ffc0 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -640,6 +640,13 @@ static struct ctl_table net_core_table[] = {
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 	},
+	{
+		.procname	= "xsk_max_per_socket_budget",
+		.data		= &net_hotdata.sysctl_xsk_max_per_socket_budget,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec
+	},
 };
 
 static struct ctl_table netns_core_table[] = {
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 72c000c0ae5f..95027f964858 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -28,13 +28,13 @@
 #include <net/netdev_lock.h>
 #include <net/netdev_rx_queue.h>
 #include <net/xdp.h>
+#include <net/hotdata.h>
 
 #include "xsk_queue.h"
 #include "xdp_umem.h"
 #include "xsk.h"
 
 #define TX_BATCH_SIZE 32
-#define MAX_PER_SOCKET_BUDGET (TX_BATCH_SIZE)
 
 void xsk_set_rx_need_wakeup(struct xsk_buff_pool *pool)
 {
@@ -424,7 +424,9 @@ bool xsk_tx_peek_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc)
 	rcu_read_lock();
 again:
 	list_for_each_entry_rcu(xs, &pool->xsk_tx_list, tx_list) {
-		if (xs->tx_budget_spent >= MAX_PER_SOCKET_BUDGET) {
+		int max_budget = READ_ONCE(net_hotdata.sysctl_xsk_max_per_socket_budget);
+
+		if (xs->tx_budget_spent >= max_budget) {
 			budget_exhausted = true;
 			continue;
 		}
-- 
2.43.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ