Skip to contentSkip to conversation

Intel FAST_FREE offload question

PATCH In review Morten Brørup 3 participants 11 messages Feb 21, 2025 – Jun 9, 2025 Network drivers

lore
Share & tools
lore
#1 lore raw
Quoted 9 lines · Morten Brørup

Intel NIC folks,

Why do the Intel network drivers, when using RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, fall back to normal freeing when the mempool cache is empty (cache->len == 0)? It doesn't make sense to me.

Example:
https://git.dpdk.org/dpdk/tree/drivers/net/intel/common/tx.h#n146

Good question. I suspect that it may be a bug and that we meant to check for size == 0 rather than len == 0.

#2 lore raw
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 21 February 2025 18.10

Quoted 4 lines · Morten Brørup

Intel NIC folks,

Why do the Intel network drivers, when using RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, fall back to normal freeing when

the

Quoted 1 line

mempool cache is empty (cache->len == 0)? It doesn't make sense to

Quoted 8 lines

me.

Quoted 4 lines

Example:
https://git.dpdk.org/dpdk/tree/drivers/net/intel/common/tx.h#n146

Good question. I suspect that it may be a bug and that we meant to check
for size == 0 rather than len == 0.

Then checking for cache == NULL suffices, because rte_mempool_default_cache() returns NULL if the cache size is 0:
https://elixir.bootlin.com/dpdk/v24.11.1/source/lib/mempool/rte_mempool.h#L1333

#3 lore raw

PATCH 1/1 net/intel: allow fast-free to empty cache

In reply to Morten Brørup

When freeing transmitted mbufs, there is no reason to send the freed mbufs directly to the ring if the cache is empty - only if it is zero size (in which case the cache pointer is NULL). Therefore, remove the empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +1 -1
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq, ci_desc_done_fn desc_done, bool ctx
 		void **cache_objs;
 		struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, rte_lcore_id());
 
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
 
 		cache_objs = &cache->objs[cache->len];
Signature · 1 line
2.43.0
author Reviewed-by on v1 1/1
#4 lore raw

RE: [PATCH] net/intel: allow fast-free to empty cache

Quoted 30 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the freed mbufs directly to the ring if the cache is empty - only if it is zero size (in which case the cache pointer is NULL). Therefore, remove the empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -2
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
 
 		cache_objs = &cache->objs[cache->len];
--
Quoted 1 line

2.43.0

Yep, it did look strange.

#5 lore raw

Re: [PATCH] net/intel: allow fast-free to empty cache

Quoted 28 lines · Morten Brørup
Quoted 28 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the freed mbufs directly to the ring if the cache is empty - only if it is zero size (in which case the cache pointer is NULL). Therefore, remove the empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -1
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
Quoted 7 lines
Quoted 3 lines

cache_objs = &cache->objs[cache->len];
--
2.43.0

Yep, it did look strange.

Thanks for review.

FYI: Given that this is in a sensitive area and we are now past rc2, I'm going to postponse merging this patch till 25.07, rather than risk it in 25.03.

/Bruce

#6 lore raw

RE: [PATCH] net/intel: allow fast-free to empty cache

Quoted 35 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 16.27

Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the

freed

Quoted 1 line
Quoted 1 line

mbufs directly to the ring if the cache is empty - only if it is

zero

Quoted 1 line
Quoted 1 line

size (in which case the cache pointer is NULL). Therefore, remove

the

Quoted 22 lines
Quoted 22 lines

empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -1
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

cache_objs = &cache->objs[cache->len];
--
2.43.0

Yep, it did look strange.

Thanks for review.

BTW, I recall other Intel drivers having the same "feature":
https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/iavf/iavf_rxtx_vec_avx512.c#L1876
https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/ice/ice_rxtx_vec_avx512.c#L891

Quoted 5 lines

FYI: Given that this is in a sensitive area and we are now past rc2, I'm going
to postponse merging this patch till 25.07, rather than risk it in 25.03.

Agree.

Quoted 2 lines

/Bruce

#7 lore raw

Re: [PATCH] net/intel: allow fast-free to empty cache

Quoted 42 lines · Morten Brørup
Quoted 42 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 16.27

Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the

freed

Quoted 1 line
Quoted 1 line

mbufs directly to the ring if the cache is empty - only if it is

zero

Quoted 1 line
Quoted 1 line

size (in which case the cache pointer is NULL). Therefore, remove

the

Quoted 29 lines
Quoted 24 lines

empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -2
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
 
 		cache_objs = &cache->objs[cache->len];
--
Quoted 1 line

2.43.0

Yep, it did look strange.

Quoted 6 lines
Quoted 1 line

Thanks for review.

BTW, I recall other Intel drivers having the same "feature":
https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/iavf/iavf_rxtx_vec_avx512.c#L1876
https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/ice/ice_rxtx_vec_avx512.c#L891

With the deduplication work I did earlier this release, this code should now be shared between ixgbe, i40e, iavf and ice drivers, so we hopefully can fix all 4 with one change.

#8 lore raw

RE: [PATCH] net/intel: allow fast-free to empty cache

Quoted 60 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 16.53

Quoted 10 lines · Morten Brørup
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 16.27

Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the

freed

Quoted 1 line
Quoted 1 line

mbufs directly to the ring if the cache is empty - only if it

is

Quoted 2 lines
Quoted 2 lines

zero

Quoted 1 line
Quoted 1 line

size (in which case the cache pointer is NULL). Therefore,

remove

Quoted 8 lines
Quoted 8 lines

the

Quoted 7 lines
Quoted 7 lines

empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/net/intel/common/tx.h ci_tx_free_bufs_vec(struct ci_tx_queue

Quoted 6 lines
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue

*txq,

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 11 lines

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -2
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
 
 		cache_objs = &cache->objs[cache->len];
--
Quoted 1 line

2.43.0

Yep, it did look strange.

Quoted 4 lines
Quoted 1 line

Thanks for review.

BTW, I recall other Intel drivers having the same "feature":

https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/iavf/iavf_r
xtx_vec_avx512.c#L1876

Quoted 1 line

https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/ice/ice_rxt
x_vec_avx512.c#L891

Quoted 1 line
Quoted 5 lines

With the deduplication work I did earlier this release, this code should
now be shared between ixgbe, i40e, iavf and ice drivers, so we hopefully
can fix all 4 with one change.

Excellent! Your deduplication already starts paying off. :-)
It looks like only the non-deduplicated idpf driver remains to be modified separately:
drivers/net/intel/idpf/idpf_common_rxtx_avx512.c

#9 lore raw

Re: [PATCH] net/intel: allow fast-free to empty cache

In reply to Morten Brørup
Quoted 28 lines · Morten Brørup
Quoted 28 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 10 March 2025 14.26

When freeing transmitted mbufs, there is no reason to send the freed mbufs directly to the ring if the cache is empty - only if it is zero size (in which case the cache pointer is NULL). Therefore, remove the empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx.h +0 -0
index d9cf4474fc..d361fe64ab 100644
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx

drivers/net/intel/common/tx.h +0 -0
 		void **cache_objs;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -1
-		if (!cache || cache->len == 0)
+		if (cache == NULL)
 			goto normal;
Quoted 7 lines
Quoted 3 lines

cache_objs = &cache->objs[cache->len];
--
2.43.0

Yep, it did look strange.

Applied to dpdk-next-net-intel.

/Bruce

Reviewed-by Tested-by [email protected]
#10 lore raw

RE: [PATCH] net/intel: allow fast-free to empty cache

[Public]

Snipped

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

When freeing transmitted mbufs, there is no reason to send the freed mbufs directly to the ring if the cache is empty - only if it is zero size (in which case the cache pointer is NULL). Therefore, remove the empty check and only check for a null cache pointer.

---
 drivers/net/intel/common/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/intel/common/tx.h index d9cf4474fc..d361fe64ab 100644

drivers/net/intel/common/tx.h +0 -0
@@ -143,7 +143,7 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq,

ci_desc_done_fn desc_done, bool ctx
void **cache_objs;
struct rte_mempool_cache *cache =
rte_mempool_default_cache(mp, rte_lcore_id());

drivers/net/intel/common/tx.h +1 -1
-           if (!cache || cache->len == 0)
+           if (cache == NULL)
                    goto normal;
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
            cache_objs = &cache->objs[cache->len];

--
2.43.0

Yep, it did look strange.

Applied to dpdk-next-net-intel.

At AMD we tested the code change on the platform AMD Siena EPYC 8534P using Intel E810 2CQDA2.

- simd: AVX512
- TEST: DPDK-TESTPMD in tx mode
- cmd: ./dpdk-testpmd -l 15,16,17 --force-max-simd-bitwidth=512 -a c1:00.0 -a c1:00.1 -- -i --nb-cores=2 --nb-ports=2 --rxq=1 --txq=1 --rxd=1024 --txd=1024 --forward-mode=txonly -a
- Before vs After
-- TX-RX Desc 1024, TX-RX 1Q: 117.12, 117.13
-- TX-RX Desc 1024, TX-RX 2Q: 117.13, 117.17
-- TX-RX Desc 2048, TX-RX 1Q: 117.16, 117.18
-- TX-RX Desc 2048, TX-RX 2Q: 117.13, 117.15

Quoted 2 lines

/Bruce