Skip to contentSkip to conversation

reduce redundant store operation for Tx free

PATCH Superseded Feifei Wang 3 participants 8 messages Dec 20, 2021 – Jan 28, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

cover reduce redundant store operation for Tx free

Reduce redundant store operation for buffer free in Tx path.

Feifei Wang (3):
net/i40e: reduce redundant store operation
net/ice: reduce redundant store operation
net/ixgbe: reduce redundant store operation

 drivers/net/i40e/i40e_rxtx.c            | 3 ---
 drivers/net/i40e/i40e_rxtx_vec_common.h | 1 -
 drivers/net/ice/ice_rxtx.c              | 2 --
 drivers/net/ixgbe/ixgbe_rxtx.c          | 1 -
 4 files changed, 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 net/i40e: reduce redundant store operation

For free buffer operation in i40e driver, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---
 drivers/net/i40e/i40e_rxtx.c            | 3 ---
 drivers/net/i40e/i40e_rxtx_vec_common.h | 1 -
 2 files changed, 4 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -3
index e4cb33dc3c..4de2be53e6 100644
@@ -1344,7 +1344,6 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 			for (j = 0; j != k; j += RTE_I40E_TX_MAX_FREE_BUF_SZ) {
 				for (i = 0; i < RTE_I40E_TX_MAX_FREE_BUF_SZ; ++i, ++txep) {
 					free[i] = txep->mbuf;
-					txep->mbuf = NULL;
 				}
 				rte_mempool_put_bulk(free[0]->pool, (void **)free,
 						RTE_I40E_TX_MAX_FREE_BUF_SZ);
@@ -1354,14 +1353,12 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 		if (m) {
 			for (i = 0; i < m; ++i, ++txep) {
 				free[i] = txep->mbuf;
-				txep->mbuf = NULL;
 			}
 			rte_mempool_put_bulk(free[0]->pool, (void **)free, m);
 		}
 	} else {
 		for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 			rte_pktmbuf_free_seg(txep->mbuf);
-			txep->mbuf = NULL;
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -1
index f9a7f46550..26deb59fc4 100644
@@ -103,7 +103,6 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 	if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
 		for (i = 0; i < n; i++) {
 			free[i] = txep[i].mbuf;
-			txep[i].mbuf = NULL;
 		}
 		rte_mempool_put_bulk(free[0]->pool, (void **)free, n);
 		goto done;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 net/ice: reduce redundant store operation

In reply to Feifei Wang

For free buffer in ice driver, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---
 drivers/net/ice/ice_rxtx.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ice/ice_rxtx.c +0 -2
index f6d8564ab8..e043335bad 100644
@@ -2893,12 +2893,10 @@ ice_tx_free_bufs(struct ice_tx_queue *txq)
 	if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
 		for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 			rte_mempool_put(txep->mbuf->pool, txep->mbuf);
-			txep->mbuf = NULL;
 		}
 	} else {
 		for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 			rte_pktmbuf_free_seg(txep->mbuf);
-			txep->mbuf = NULL;
 		}
 	}
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/3 net/ixgbe: reduce redundant store operation

In reply to Feifei Wang

For free buffer in ixgbe driver, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ixgbe/ixgbe_rxtx.c +0 -1
index d7c80d4242..9f3f2e9b50 100644
@@ -120,7 +120,6 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq)
 	for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 		/* free buffers one at a time */
 		m = rte_pktmbuf_prefree_seg(txep->mbuf);
-		txep->mbuf = NULL;
 
 		if (unlikely(m == NULL))
 			continue;
Signature · 1 line
2.25.1
#4 lore raw

RE: [PATCH 3/3] net/ixgbe: reduce redundant store operation

Quoted 24 lines

-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Monday, December 20, 2021 13:51
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; [email protected]; Feifei Wang <[email protected]>; Ruifeng Wang <[email protected]>
Subject: [PATCH 3/3] net/ixgbe: reduce redundant store operation

For free buffer in ixgbe driver, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
index d7c80d4242..9f3f2e9b50 100644

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq) · line 123

Quoted 4 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -1
@@ -120,7 +120,6 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq)
 	for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 		/* free buffers one at a time */
 		m = rte_pktmbuf_prefree_seg(txep->mbuf);
-		txep->mbuf = NULL;

Not sure, but at least found:

static void __rte_cold ixgbe_tx_queue_release_mbufs(struct ixgbe_tx_queue *txq)

{
	unsigned i;

	if (txq->sw_ring != NULL) {
		for (i = 0; i < txq->nb_tx_desc; i++) {
			if (txq->sw_ring[i].mbuf != NULL) {  <---------------------------- ?
				rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
				txq->sw_ring[i].mbuf = NULL;
			}
		}
	}
}
Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -1
 		if (unlikely(m == NULL))
 			continue;
--

2.25.1

#5 lore raw

回复: [PATCH 3/3] net/ixgbe: reduce redundant store operation

Quoted 49 lines

-----邮件原件-----
发件人: Wang, Haiyue <[email protected]>
发送时间: Monday, December 20, 2021 3:25 PM
收件人: Feifei Wang <[email protected]>
抄送: [email protected]; nd <[email protected]>; Ruifeng Wang <[email protected]>
主题: RE: [PATCH 3/3] net/ixgbe: reduce redundant store operation

Quoted 25 lines

-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Monday, December 20, 2021 13:51
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; [email protected]; Feifei Wang <[email protected]>; Ruifeng Wang <[email protected]>
Subject: [PATCH 3/3] net/ixgbe: reduce redundant store operation

For free buffer in ixgbe driver, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 1 -
 1 file changed, 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index d7c80d4242..9f3f2e9b50 100644

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq) · line 123

Quoted 4 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -1
@@ -120,7 +120,6 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq)
 	for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
 		/* free buffers one at a time */
 		m = rte_pktmbuf_prefree_seg(txep->mbuf);
-		txep->mbuf = NULL;

Not sure, but at least found:

static void __rte_cold

ixgbe_tx_queue_release_mbufs(struct ixgbe_tx_queue *txq) {
	unsigned i;

	if (txq->sw_ring != NULL) {
		for (i = 0; i < txq->nb_tx_desc; i++) {
			if (txq->sw_ring[i].mbuf != NULL) {  <--------------------
Quoted 9 lines

-------- ?
rte_pktmbuf_free_seg(txq-

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq) · line 123

Quoted 1 line
drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
 sw_ring[i].mbuf);
				txq->sw_ring[i].mbuf = NULL;
			}
		}
	}
}

Thanks for your remind. I check the function"xx_tx_queue_release_mbufs" and "xx_tx_done_cleanup_full" which have the check for 'sw_ring->buf == NULL'. I find the scheme of free buffers in scalar path and vector path are different:
For scalar, it should support jumbo frame, so it cannot use 'tx_next_dd' to find free buffer index
For vector, free a packet means free a buffer, just use tx_next_dd can find the start index of free buffer. At last, store operation of NULL for freed buffer is necessary for scalar path. And I will just keep the vector path path.

Quoted 5 lines
Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -1
 		if (unlikely(m == NULL))
 			continue;
--

2.25.1

#6 lore raw

PATCH v3 1/1 net/i40e: reduce redundant reset operation

In reply to Feifei Wang

For free buffer operation in i40e vector path, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check. Thus reset of mbuf is unnecessary and can be omitted.

---

v2: remove the change for scalar path due to scalar path needs to check whether the mbuf is 'NULL' to release and clean up (Haiyue)

v3: add comments to remind reset mbuf is unnecessary here (Qi Zhang)

 drivers/net/i40e/i40e_rxtx_vec_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_rxtx_vec_common.h +1 -1
index f9a7f46550..959832ed6a 100644
@@ -103,7 +103,7 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 	if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
 		for (i = 0; i < n; i++) {
 			free[i] = txep[i].mbuf;
-			txep[i].mbuf = NULL;
+			/* no need to reset txep[i].mbuf in vector path */
 		}
 		rte_mempool_put_bulk(free[0]->pool, (void **)free, n);
 		goto done;
Signature · 1 line
2.25.1
Acked-by on v3 1/1 Applied
#7 lore raw

RE: [PATCH v3] net/i40e: reduce redundant reset operation

Quoted 10 lines

-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Thursday, January 27, 2022 3:40 PM
To: Xing, Beilei <[email protected]>
Cc: [email protected]; [email protected]; Feifei Wang <[email protected]>; Ruifeng Wang <[email protected]>
Subject: [PATCH v3] net/i40e: reduce redundant reset operation

Quoted 8 lines

For free buffer operation in i40e vector path, it is unnecessary to store 'NULL' into txep.mbuf. This is because when putting mbuf into Tx queue, tx_tail is the sentinel. And when doing tx_free, tx_next_dd is the sentinel. In all processes, mbuf==NULL is not a condition in check.
Thus reset of mbuf is unnecessary and can be omitted.

Applied to dpdk-next-net-intel.

Thanks
Qi