From: Jason Xing <kerneljasonxing@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, bjorn@kernel.org, magnus.karlsson@intel.com,
maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com,
sdf@fomichev.me, ast@kernel.org, daniel@iogearbox.net,
hawk@kernel.org, john.fastabend@gmail.com
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Jason Xing <kernelxing@tencent.com>
Subject: [PATCH net-next 1/2] net: xsk: make MAX_PER_SOCKET_BUDGET tunable
Date: Tue, 17 Jun 2025 08:22:35 +0800 [thread overview]
Message-ID: <20250617002236.30557-2-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20250617002236.30557-1-kerneljasonxing@gmail.com>
From: Jason Xing <kernelxing@tencent.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@tencent.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
next prev parent reply other threads:[~2025-06-17 0:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 0:22 [PATCH net-next 0/2] net: xsk: add two sysctl knobs Jason Xing
2025-06-17 0:22 ` Jason Xing [this message]
2025-06-17 0:22 ` [PATCH net-next 2/2] net: xsk: make xsk_tx_batch_size tunable Jason Xing
2025-06-17 1:11 ` [PATCH net-next 0/2] net: xsk: add two sysctl knobs Stanislav Fomichev
2025-06-17 2:15 ` Jason Xing
2025-06-17 17:46 ` Stanislav Fomichev
2025-06-17 19:17 ` Joe Damato
2025-06-18 0:31 ` Jason Xing
2025-06-18 0:29 ` Jason Xing
2025-06-18 6:59 ` Jason Xing
2025-06-18 17:57 ` Willem de Bruijn
2025-06-18 19:24 ` Jason Xing
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=20250617002236.30557-2-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/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).