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 2/2] net: xsk: make xsk_tx_batch_size tunable
Date: Tue, 17 Jun 2025 08:22:36 +0800 [thread overview]
Message-ID: <20250617002236.30557-3-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20250617002236.30557-1-kerneljasonxing@gmail.com>
From: Jason Xing <kernelxing@tencent.com>
In some cases, users probably expect to see xsk_generic_xmit() can
handle more desc at one time. Make it tunable and it would be similar
with how dev_tx_weight works in xsk path.
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
include/net/hotdata.h | 1 +
net/core/hotdata.c | 3 ++-
net/core/sysctl_net_core.c | 8 ++++++++
net/xdp/xsk.c | 4 +---
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/net/hotdata.h b/include/net/hotdata.h
index 2df1e8175a85..862bd168fdd8 100644
--- a/include/net/hotdata.h
+++ b/include/net/hotdata.h
@@ -41,6 +41,7 @@ struct net_hotdata {
int sysctl_skb_defer_max;
int sysctl_mem_pcpu_rsv;
int sysctl_xsk_max_per_socket_budget;
+ int sysctl_xsk_tx_batch_size;
};
#define inet_ehash_secret net_hotdata.tcp_protocol.secret
diff --git a/net/core/hotdata.c b/net/core/hotdata.c
index 5131714eee63..e08fd0ee1b05 100644
--- a/net/core/hotdata.c
+++ b/net/core/hotdata.c
@@ -20,6 +20,7 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
.sysctl_max_skb_frags = MAX_SKB_FRAGS,
.sysctl_skb_defer_max = 64,
.sysctl_mem_pcpu_rsv = SK_MEMORY_PCPU_RESERVE,
- .sysctl_xsk_max_per_socket_budget = 32
+ .sysctl_xsk_max_per_socket_budget = 32,
+ .sysctl_xsk_tx_batch_size = 32
};
EXPORT_SYMBOL(net_hotdata);
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 9f9946b7ffc0..73be2d9e6bab 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -647,6 +647,14 @@ static struct ctl_table net_core_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec
},
+ {
+ .procname = "xsk_tx_batch_size",
+ .data = &net_hotdata.sysctl_xsk_tx_batch_size,
+ .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 95027f964858..4215a40abb69 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -34,8 +34,6 @@
#include "xdp_umem.h"
#include "xsk.h"
-#define TX_BATCH_SIZE 32
-
void xsk_set_rx_need_wakeup(struct xsk_buff_pool *pool)
{
if (pool->cached_need_wakeup & XDP_WAKEUP_RX)
@@ -780,8 +778,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
static int __xsk_generic_xmit(struct sock *sk)
{
+ u32 max_batch = READ_ONCE(net_hotdata.sysctl_xsk_tx_batch_size);
struct xdp_sock *xs = xdp_sk(sk);
- u32 max_batch = TX_BATCH_SIZE;
bool sent_frame = false;
struct xdp_desc desc;
struct sk_buff *skb;
--
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 ` [PATCH net-next 1/2] net: xsk: make MAX_PER_SOCKET_BUDGET tunable Jason Xing
2025-06-17 0:22 ` Jason Xing [this message]
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-3-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).