* Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop
@ 2025-12-08 15:56 Yan Yanovsky
2025-12-08 19:02 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Yan Yanovsky @ 2025-12-08 15:56 UTC (permalink / raw)
To: dev, qi.z.zhang; +Cc: ciara.loftus
From 191d90eaab50c6855ee746361e7e735572f3b1ce Mon Sep 17 00:00:00 2001
From: Yan Yanovsky <yan.yanovsky@catonetworks.com>
Date: Sun, 7 Dec 2025 18:10:45 +0200
Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop
Signed-off-by: Yan Yanovsky <yan.yanovsky@catonetworks.com>
---
drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index b6ec9bf490..dc34f1a29e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -80,6 +80,7 @@ RTE_LOG_REGISTER_DEFAULT(af_xdp_logtype, NOTICE);
#define ETH_AF_XDP_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
#define ETH_AF_XDP_MP_KEY "afxdp_mp_send_fds"
+#define MAX_TX_KICK_TRIES 10
static int afxdp_dev_count;
@@ -480,22 +481,29 @@ static void
kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons *cq)
{
struct xsk_umem_info *umem = txq->umem;
+ int tries = 0;
+ /* Pull completion queue entries to free UMEM buffers */
pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);
- if (tx_syscall_needed(&txq->tx))
- while (send(xsk_socket__fd(txq->pair->xsk), NULL,
- 0, MSG_DONTWAIT) < 0) {
- /* some thing unexpected */
- if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
- break;
+ if (!tx_syscall_needed(&txq->tx))
+ return;
- /* pull from completion queue to leave more space */
- if (errno == EAGAIN)
+ for (tries = 0; tries < MAX_TX_KICK_TRIES; tries++) {
+ if (send(xsk_socket__fd(txq->pair->xsk), NULL, 0,
+ MSG_DONTWAIT) >= 0)
+ break;
+ if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
+ break;
+
+ if (errno == EAGAIN) {
+ /* Kernel TX ring has no space or UMEM completion queue
+ * is lagging behind. Try pulling CQ to free room. */\
pull_umem_cq(umem,
- XSK_RING_CONS__DEFAULT_NUM_DESCS,
- cq);
+ XSK_RING_CONS__DEFAULT_NUM_DESCS,
+ cq);
}
+ }
}
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop
2025-12-08 15:56 Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop Yan Yanovsky
@ 2025-12-08 19:02 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2025-12-08 19:02 UTC (permalink / raw)
To: Yan Yanovsky; +Cc: dev, qi.z.zhang, ciara.loftus
On Mon, 8 Dec 2025 15:56:37 +0000
Yan Yanovsky <yan.yanovsky@catonetworks.com> wrote:
> From 191d90eaab50c6855ee746361e7e735572f3b1ce Mon Sep 17 00:00:00 2001
> From: Yan Yanovsky <yan.yanovsky@catonetworks.com>
> Date: Sun, 7 Dec 2025 18:10:45 +0200
> Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop
> Signed-off-by: Yan Yanovsky <yan.yanovsky@catonetworks.com>
>
Minor cosmetic changes needed.
> drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index b6ec9bf490..dc34f1a29e 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -80,6 +80,7 @@ RTE_LOG_REGISTER_DEFAULT(af_xdp_logtype, NOTICE);
> #define ETH_AF_XDP_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
>
> #define ETH_AF_XDP_MP_KEY "afxdp_mp_send_fds"
> +#define MAX_TX_KICK_TRIES 10
>
> static int afxdp_dev_count;
>
> @@ -480,22 +481,29 @@ static void
> kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons *cq)
> {
> struct xsk_umem_info *umem = txq->umem;
> + int tries = 0;
>
Unnecessary initialization
> + /* Pull completion queue entries to free UMEM buffers */
> pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);
>
> - if (tx_syscall_needed(&txq->tx))
> - while (send(xsk_socket__fd(txq->pair->xsk), NULL,
> - 0, MSG_DONTWAIT) < 0) {
> - /* some thing unexpected */
> - if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
> - break;
> + if (!tx_syscall_needed(&txq->tx))
> + return;
>
> - /* pull from completion queue to leave more space */
> - if (errno == EAGAIN)
> + for (tries = 0; tries < MAX_TX_KICK_TRIES; tries++) {
Suggest (but not required) to put definition here as:
for (unsigned int tries = 0; tries < MAX_TX_KICK_TRIES; tries++) {
> + if (send(xsk_socket__fd(txq->pair->xsk), NULL, 0,
> + MSG_DONTWAIT) >= 0)
> + break;
> + if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
> + break;
> +
> + if (errno == EAGAIN) {
> + /* Kernel TX ring has no space or UMEM completion queue
> + * is lagging behind. Try pulling CQ to free room. */\
> pull_umem_cq(umem,
Do not put line continuation on the comment.
Original indent is better. I.e line up args on first to same column
> - XSK_RING_CONS__DEFAULT_NUM_DESCS,
> - cq);
> + XSK_RING_CONS__DEFAULT_NUM_DESCS,
> + cq);
> }
> + }
> }
>
> #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
Subject is repeated twice.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-08 19:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-08 15:56 Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop Yan Yanovsky
2025-12-08 19:02 ` Stephen Hemminger
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).