net/af_xdp: fix Tx halt when no recv packets
PATCH 1/1 net/af_xdp: fix Tx halt when no recv packets
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called send(). So we need to issue a send() even when the allocation fails so that kernel will start to consume packets again.
Commit 45bba02c95b0 ("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps the need_wakeup feature for Tx.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +14 -14
@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }
@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts; txq->stats.tx_bytes += tx_bytes;
Signature · 1 line
2.17.1
Quoted 11 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packets
Quoted 3 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consume packets again.
So "allocation fails" means " xsk_ring_prod__reserve" fail right?
I don't understand when xsk_ring_prod__needs_wakeup is true why kernel will stop Tx packet at this situation would you share more insight?
Thanks
Qi
Quoted 61 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +14
-14@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 11 lines · Qi Z
Quoted 11 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packets
Quoted 5 lines
Quoted 3 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consume packets again.So "allocation fails" means "
xsk_ring_prod__reserve" fail right?
Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share more insight?
Actually, the fail case is xsk_ring_prod__needs_wakeup is false, then we can't issue a send() when xsk_ring_prod__reserve fails.
Thanks,
Xiaolong
Quoted 66 lines
Thanks
QiQuoted 61 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +14
-14@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 30 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 11 lines · Qi Z
Quoted 11 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 3 lines
Quoted 3 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumepackets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?
Quoted 7 lines
Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share more insight?Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.
Sorry, I think my question should be for the case when xsk_ring_prod__needs_wakeup is false,
I don't understand why we need to handle different at below two situations
1. when xsk_ring_prod__reserve fails
2. normal tx scenario.
My understanding is when xsk_ring_prod__needs_wakeup(tx) is false, which means Tx is ongoing, we don't need to wake up kernel to continue.
Quoted 71 lines
Thanks,
XiaolongQuoted 67 lines
Thanks
QiQuoted 62 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +14
-14@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 35 lines · Qi Z
Quoted 35 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 11 lines · Qi Z
Quoted 11 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 3 lines
Quoted 3 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumepackets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share more insight?
Quoted 9 lines
Quoted 2 lines
Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.Sorry, I think my question should be for the case when
xsk_ring_prod__needs_wakeupis false,
I don't understand why we need to handle different at below two situations
1. whenxsk_ring_prod__reservefails
2. normal tx scenario.
My understanding is whenxsk_ring_prod__needs_wakeup(tx)is false, which means Tx is ongoing, we don't need to wake up kernel to continue.
The problem is that kernel does not guarantee that all entries are sent for Tx. There are a number of reasons that this might not happen, but usually some Rx packet will at some point in time in the very short future trigger further Tx processing and the packets will be sent. But if you only have Tx processing and no Rx at all, you have to trigger a sento() again.
Thanks,
Xiaolong
Quoted 71 lines
Quoted 71 lines
Thanks,
XiaolongQuoted 67 lines
Thanks
QiQuoted 62 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +14
-14@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 57 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 11:09 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 27 lines · Qi Z
Quoted 27 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 15 lines · Qi Z
Quoted 15 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsThe kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumeQuoted 8 lines
Quoted 8 lines
packets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share moreinsight?
Quoted 9 lines
Quoted 3 lines
Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.Sorry, I think my question should be for the case when
xsk_ring_prod__needs_wakeupis false, I don't understand why we need to handle different at below two situations 1. whenxsk_ring_prod__reservefails 2. normal tx scenario.
My understanding is whenxsk_ring_prod__needs_wakeup(tx)is false,
Quoted 8 lines
which means Tx is ongoing, we don't need to wake up kernel to continue.
Quoted 1 line
The problem is that kernel does not guarantee that all entries are sent for Tx. There are a number of reasons that this might not happen, but usually some Rx packet will at some point in time in the very short future trigger further Tx processing and the packets will be sent. But if you only have Tx processing and no Rx at all, you have to trigger a
sento()again.
Ok , so the question is why we have below code.
#if defined(XDP_USE_NEED_WAKEUP)
if (xsk_ring_prod__needs_wakeup(&txq->tx))
#endif kick_tx(txq);
Here, when xsk_ring_prod__needs_wakeup is false, we can skip kick_tx (send), but why same "if check" can't be applied to the case when xsk_ring_prod__reserve failed?
Btw, think about below case
when xsk_ring_prod_reserve failed, if we don't kick_tx, and no following rx happens,
does that mean the remain packets in tx queue will never get chance be transmitted?, what happen if the last tx_burst is never be called?
Quoted 77 lines
Thanks,
XiaolongQuoted 30 lines
Quoted 30 lines
Thanks,
XiaolongQuoted 26 lines
Thanks
QiQuoted 22 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +0
-0@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq)
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-7-#if defined(XDP_USE_NEED_WAKEUP) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif - while (send(xsk_socket__fd(txq->pair->xsk), NULL, - 0, MSG_DONTWAIT) < 0) { - /* some thing unexpected */ - if (errno != EBUSY && errno != EAGAIN && errno !=EINTR)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq)
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-5-break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) - pull_umem_cq(umem,
ETH_AF_XDP_TX_BATCH_SIZE);Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +14
-2- } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 66 lines · Qi Z
Quoted 57 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 11:09 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 27 lines · Qi Z
Quoted 27 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 15 lines · Qi Z
Quoted 15 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsThe kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumeQuoted 8 lines
Quoted 8 lines
packets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share moreinsight?
Quoted 9 lines
Quoted 3 lines
Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.Sorry, I think my question should be for the case when
xsk_ring_prod__needs_wakeupis false, I don't understand why we need to handle different at below two situations 1. whenxsk_ring_prod__reservefails 2. normal tx scenario.
My understanding is whenxsk_ring_prod__needs_wakeup(tx)is false,Quoted 8 lines
which means Tx is ongoing, we don't need to wake up kernel to continue.
Quoted 1 line
The problem is that kernel does not guarantee that all entries are sent for Tx. There are a number of reasons that this might not happen, but usually some Rx packet will at some point in time in the very short future trigger further Tx processing and the packets will be sent. But if you only have Tx processing and no Rx at all, you have to trigger a
sento()again.
Quoted 7 lines
Ok , so the question is why we have below code.
#ifdefined(XDP_USE_NEED_WAKEUP)
if (xsk_ring_prod__needs_wakeup(&txq->tx))#endif kick_tx(txq);Here, when
xsk_ring_prod__needs_wakeupis false, we can skipkick_tx(send), but why same "if check" can't be applied to the case whenxsk_ring_prod__reservefailed?
When the system is running out of Tx entries, it needs some explicit action to trigger kernel consumes the Tx buffers.
Quoted 4 lines
Btw, think about below case
whenxsk_ring_prod_reservefailed, if we don'tkick_tx, and no following rx happens,
does that mean the remain packets in tx queue will never get chance be transmitted?, what happen if the lasttx_burstis never be called?
This is exactly the issue this patch try to fix, in this case, xsk_ring_prod__reserve failure means there is no more available entries in tx queue, if we don't call send/sendto or there is no rx traffic, Tx just halts.
Thanks,
Xiaolong
Quoted 78 lines
Quoted 78 lines
Thanks,
XiaolongQuoted 30 lines
Quoted 30 lines
Thanks,
XiaolongQuoted 26 lines
Thanks
QiQuoted 22 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +0
-0@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq)
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-7-#if defined(XDP_USE_NEED_WAKEUP) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif - while (send(xsk_socket__fd(txq->pair->xsk), NULL, - 0, MSG_DONTWAIT) < 0) { - /* some thing unexpected */ - if (errno != EBUSY && errno != EAGAIN && errno !=EINTR)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq)
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-5-break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) - pull_umem_cq(umem,
ETH_AF_XDP_TX_BATCH_SIZE);Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +14
-2- } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 98 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Wednesday, September 11, 2019 8:56 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 58 lines · Qi Z
Quoted 58 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 11:09 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 28 lines · Qi Z
Quoted 28 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 16 lines · Qi Z
Quoted 16 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsThe kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumeQuoted 8 lines
Quoted 8 lines
packets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share moreinsight?
Quoted 9 lines
Quoted 3 lines
Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.Sorry, I think my question should be for the case when
xsk_ring_prod__needs_wakeupis false, I don't understand why we need to handle different at below two situations 1. whenxsk_ring_prod__reservefails 2. normal tx scenario.
My understanding is whenxsk_ring_prod__needs_wakeup(tx)is false,Quoted 4 lines
Quoted 4 lines
which means Tx is ongoing, we don't need to wake up kernel to continue.
Quoted 1 line
The problem is that kernel does not guarantee that all entries are sent for
Tx.
Quoted 4 lines
Quoted 4 lines
There are a number of reasons that this might not happen, but usually some Rx packet will at some point in time in the very short future trigger further Tx processing and the packets will be sent. But if you only have Tx processing and no Rx at all, you have to trigger a
sento()again.
Quoted 8 lines
Ok , so the question is why we have below code.
#ifdefined(XDP_USE_NEED_WAKEUP)
if (xsk_ring_prod__needs_wakeup(&txq->tx))#endif kick_tx(txq);Here, when
xsk_ring_prod__needs_wakeupis false, we can skipkick_tx(send), but why same "if check" can't be applied to the case when
xsk_ring_prod__reservefailed?When the system is running out of Tx entries, it needs some explicit action to trigger kernel consumes the Tx buffers.
Quoted 4 lines
Btw, think about below case
whenxsk_ring_prod_reservefailed, if we don'tkick_tx, and no following rx happens, does that mean the remain packets in tx queue will
Quoted 6 lines
never get chance be transmitted?, what happen if the last
tx_burstis never be called?This is exactly the issue this patch try to fix, in this case,
xsk_ring_prod__reservefailure means there is no more available entries in tx queue, if we don't call send/sendto or there is no rx traffic, Tx just halts.
the problem I saw is if a packet is transmitted in a tx_burst, it may get chance not be transmitted immediately by kernel (wait for a trigger), it may rely on a "send" call from next tx_burst.(that's the patch does). But this does not looks like a correct driver behavior, since we can't assume application will do tx_burst all the time. I think in every tx_burst we need to guarantee kernel tx should be activated immediately, trigger a Tx for a previous tx_burst should not be the case.
Quoted 87 lines
Thanks,
XiaolongQuoted 10 lines
Quoted 10 lines
Thanks,
XiaolongQuoted 5 lines
Quoted 5 lines
Thanks,
XiaolongQuoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Thanks
QiQuoted 2 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeupfeature")
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
breaks above rule by adding some condition to send, this patch fixes it while still keeps the
need_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +0
-0@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq) { · line 294
Quoted 7 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-7-#if defined(XDP_USE_NEED_WAKEUP) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif - while (send(xsk_socket__fd(txq->pair->xsk), NULL, - 0, MSG_DONTWAIT) < 0) { - /* some thing unexpected */ - if (errno != EBUSY && errno != EAGAIN && errno !=EINTR)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq) { · line 297
Quoted 3 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-3-break ; - -/* pull from completion queue to leave more space */
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq) { · line 299
Quoted 2 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-2-if (errno ==EAGAIN ) - pull_umem_cq(umem,
ETH_AF_XDP_TX_BATCH_SIZE);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq) { · line 291
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +4
-1- } + while (send(xsk_socket__fd(txq->pair->xsk), NULL, + 0, MSG_DONTWAIT) < 0) { + /* some thing unexpected */ + if (errno != EBUSY && errno != EAGAIN && errno !=EINTR)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c kick_tx(struct pkt_tx_queue *txq) { · line 296
Quoted 5 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +5
-0+break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) + pull_umem_cq(umem,
ETH_AF_XDP_TX_BATCH_SIZE);Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/af_xdp/rte_eth_af_xdp.c eth_af_xdp_tx(void *queue, struct
Quoted 4 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +1
-0+ }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct
rte_mbufQuoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +4
-1**bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 30 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 9:54 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>
Subject: Re: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 11 lines · Qi Z
Quoted 11 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Tuesday, September 10, 2019 12:13 AM
To: Yigit, Ferruh <[email protected]>; Loftus, Ciara <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH]net/af_xdp: fix Tx halt when no recv packetsQuoted 3 lines
Quoted 3 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consumepackets again.
Quoted 2 lines
So "allocation fails" means "
xsk_ring_prod__reserve" fail right?
Quoted 7 lines
Yes.
Quoted 2 lines
I don't understand when
xsk_ring_prod__needs_wakeupis true why kernel will stop Tx packet at this situation would you share more insight?Actually, the fail case is
xsk_ring_prod__needs_wakeupis false, then we can't issue asend()whenxsk_ring_prod__reservefails.
Sorry, I think my question should be for the case when xsk_ring_prod__needs_wakeup is false,
I don't understand why we need to handle different at below two situations
1. when xsk_ring_prod__reserve fails
2. normal tx scenario.
My understanding is when xsk_ring_prod__needs_wakeup(tx) is false, which means Tx is ongoing, we don't need to wake up kernel to continue.
Quoted 71 lines
Thanks,
XiaolongQuoted 67 lines
Thanks
QiQuoted 62 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +14
-14@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) - if (xsk_ring_prod__needs_wakeup(&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1
Quoted 5 lines
The kernel only consumes Tx packets if we have some Rx traffic on specified queue or we have called
send(). So we need to issue asend()even when the allocation fails so that kernel will start to consume packets again.
Quoted 8 lines
Commit
45bba02c95b0("net/af_xdp: support need wakeup feature") breaks above rule by adding some condition to send, this patch fixes it while still keeps theneed_wakeupfeature for Tx.Fixes 45bba02c95b0 ("net/af_xdp: support need wakeup feature")Signed-off-by Xiaolong Ye <[email protected]>
Thanks for the patch Xiaolong.
Verified that this resolved an issue whereby when transmitting in one direction from a NIC PMD to the AF_XDP PMD, the AF_XDP PMD would stop transmitting after a short time.
Thanks,
Ciara
Quoted 56 lines
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/af_xdp/rte_eth_af_xdp.c +10
-13@@ -286,19 +286,16 @@ kick_tx(struct pkt_tx_queue *txq) {struct xsk_umem_info *umem = txq->pair->umem; -#if defined(XDP_USE_NEED_WAKEUP ) -if (xsk_ring_prod__needs_wakeup (&txq->tx)) -#endif -while (send (xsk_socket__fd (txq->pair->xsk),NULL , -0 ,MSG_DONTWAIT ) <0 ) { -/* some thing unexpected */ -if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR) -break ; - -/* pull from completion queue to leave more space */ -if (errno ==EAGAIN ) -pull_umem_cq (umem, ETH_AF_XDP_TX_BATCH_SIZE); - } +while (send (xsk_socket__fd (txq->pair->xsk),NULL , +0 ,MSG_DONTWAIT ) <0 ) { +/* some thing unexpected */ +if (errno !=EBUSY && errno !=EAGAIN && errno !=EINTR ) +break ; + +/* pull from completion queue to leave more space */ +if (errno ==EAGAIN ) +pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); + }drivers/net/af_xdp/rte_eth_af_xdp.c +4
-1pull_umem_cq (umem,ETH_AF_XDP_TX_BATCH_SIZE ); }@@ -367,7 +364,10 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)xsk_ring_prod__submit (&txq->tx, nb_pkts); -kick_tx (txq); +#if defined(XDP_USE_NEED_WAKEUP ) + if (xsk_ring_prod__needs_wakeup(&txq->tx)) +#endif +kick_tx (txq); txq->stats.tx_pkts += nb_pkts;
txq->stats.tx_bytes+=tx_bytes;
--
2.17.1