Skip to contentSkip to conversation

app/testpmd: avoid mbuf pool memzone name collision

PATCH Superseded Mujahed Mohammed 2 participants 4 messages Nov 15 – Nov 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: avoid mbuf pool memzone name collision

From 87f15e6967bae3d7d066598b17069958e46ae18d Mon Sep 17 00:00:00 2001
From: Mujahed Mohammed <[email protected]>
Date: Wed, 11 Nov 2026 10:16:37 +0200
Subject: [PATCH] app/testpmd: avoid mbuf pool memzone name collision

Additional mbuf pools append a numeric size index to the base pool name. Mempool backing chunks also append a numeric chunk index. If the base pool needs multiple chunks, its chunk name can therefore match the metadata memzone name of an additional pool.

Add an s marker before additional pool size indexes to keep the two namespaces distinct while retaining the original index-zero pool name.

Fixes 26cbb4191e91 ("app/testpmd: add multiple pools per core creation")
---
 .mailmap               | 1 +
 app/test-pmd/testpmd.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
.mailmap +1 -0
index a4af517007..fc7750a006 100644
@@ -1183,6 +1183,7 @@ Morten Brørup <[email protected]>
 Moti Haimovsky <[email protected]>
 Muhammad Ahmad <[email protected]>
 Muhammad Bilal <[email protected]>
+Mujahed Mohammed <[email protected]>
 Mukesh Dua <[email protected]>
 Mukul Katiyar <[email protected]>
 Murphy Yang <[email protected]>
app/test-pmd/testpmd.h +2 -1
index 2ca4aaf086..5736e60a57 100644
@@ -893,8 +893,9 @@ mbuf_poolname_build(unsigned int sock_id, char *mp_name,
 		snprintf(mp_name, name_size,
 			 MBUF_POOL_NAME_PFX "_%u", sock_id);
 	else
+		/* Keep pool indexes distinct from mempool chunk suffixes. */
 		snprintf(mp_name, name_size,
-			 MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
+			 MBUF_POOL_NAME_PFX "_%hu_s%hu", (uint16_t)sock_id, idx);
 }
 
 static inline struct rte_mempool *
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 app/testpmd: avoid mbuf pool memzone name collision

Additional mbuf pools append a numeric size index to the base pool name. Mempool backing chunks also append a numeric chunk index. If the base pool needs multiple chunks, its chunk name can therefore match the metadata memzone name of an additional pool.

Add an s marker before additional pool size indexes to keep the two namespaces distinct while retaining the original index-zero pool name.

Fixes 26cbb4191e91 ("app/testpmd: add multiple pools per core creation")
---
 .mailmap               | 1 +
 app/test-pmd/testpmd.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
.mailmap +1 -0
index a4af517007..fc7750a006 100644
@@ -1183,6 +1183,7 @@ Morten Brørup <[email protected]>
 Moti Haimovsky <[email protected]>
 Muhammad Ahmad <[email protected]>
 Muhammad Bilal <[email protected]>
+Mujahed Mohammed <[email protected]>
 Mukesh Dua <[email protected]>
 Mukul Katiyar <[email protected]>
 Murphy Yang <[email protected]>
app/test-pmd/testpmd.h +2 -1
index 2ca4aaf086..5736e60a57 100644
@@ -893,8 +893,9 @@ mbuf_poolname_build(unsigned int sock_id, char *mp_name,
 		snprintf(mp_name, name_size,
 			 MBUF_POOL_NAME_PFX "_%u", sock_id);
 	else
+		/* Keep pool indexes distinct from mempool chunk suffixes. */
 		snprintf(mp_name, name_size,
-			 MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
+			 MBUF_POOL_NAME_PFX "_%hu_s%hu", (uint16_t)sock_id, idx);
 }
 
 static inline struct rte_mempool *
Signature · 1 line
2.43.0
#2 lore raw
Quoted 9 lines · On Mon, 16 Nov 2026 13:25:53 +0200 Mujahed Mohammed <[email protected]> wrote:

Additional mbuf pools append a numeric size index to the base pool name. Mempool backing chunks also append a numeric chunk index. If the base pool needs multiple chunks, its chunk name can therefore match the metadata memzone name of an additional pool.

Add an s marker before additional pool size indexes to keep the two namespaces distinct while retaining the original index-zero pool name.

Quoted 6 lines
Fixes 26cbb4191e91 ("app/testpmd: add multiple pools per core creation")

---

Looks ok, but I like the AI suggestion to fix it in mempoll code not just in testpmd.

---

The collision is not testpmd specific. rte_mempool_populate_default() names chunks MP_<name>_<id>, which shares a namespace with the pool metadata memzone MP_<name>. Any application with pools "foo" and "foo_1" can hit this once "foo" spans more than one chunk.

Please fix it in lib/mempool instead, e.g. use a distinct prefix of the same length for chunk memzones ("MC_%s_%u"). Nothing looks up chunk memzones by name, and the name length budget is unchanged.

Also please add the reproduction (command line and memory setup that forces multiple chunks) to the commit message.

Minor: braces around the else body if a comment is added there, and no blank line between Fixes: and Cc: stable.

#3 lore raw

PATCH v3 1/1 mempool: avoid memzone name collision

In reply to Mujahed Mohammed

Mempool metadata uses MP_<name>, while default-populated backing chunks use MP_<name>_<id>. If a pool named "foo" spans more than one chunk, chunk 1 is named MP_foo_1. Creating a pool named "foo_1" then fails to reserve its MP_foo_1 metadata memzone with EEXIST.

This can be reproduced on a two-NUMA-node system using 2 MiB hugepages with the following memory setup:

    HugePages_Total: 2048
    HugePages_Free:  2048
    Hugepagesize:    2048 kB

Run testpmd in legacy-memory mode so the first pool spans chunks:

    dpdk-testpmd -n 4 \
        -a 0000:08:00.0 -a 0000:08:00.1 \
        --legacy-mem --socket-mem=0,2048 -- \
        -i --nb-cores=3 --rxq=8 --txq=8 \
        --rxd=2048 --txd=2048 --socket-num=1 --no-numa \
        --mbuf-size=2972,612,512 \
        --rxpkts=2844,612,512 \
        --total-num-mbufs=196608 --enable-scatter

The first pool's chunk 1 and the second pool's metadata both request MP_mb_pool_1_1.

Use MC_<name>_<id> for chunk memzones, keeping MP_<name> for mempool metadata. Chunk memzones are not looked up by name, and the new prefix keeps the existing name-length budget.

Fixes d1d914ebbc25 ("mempool: allocate in several memory chunks by default")

---
v3:
- Move the fix from testpmd to the mempool library.
- Use the MC_ prefix for backing chunk memzones.
- Add the reproducer and hugepage setup to the commit message.

 .mailmap                  | 1 +
 lib/mempool/rte_mempool.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
.mailmap +1 -0
index a4af517007..fc7750a006 100644
@@ -1183,6 +1183,7 @@ Morten Brørup <[email protected]>
 Moti Haimovsky <[email protected]>
 Muhammad Ahmad <[email protected]>
 Muhammad Bilal <[email protected]>
+Mujahed Mohammed <[email protected]>
 Mukesh Dua <[email protected]>
 Mukul Katiyar <[email protected]>
 Murphy Yang <[email protected]>
lib/mempool/rte_mempool.c +1 -1
index 069aabaa70..8f3c88aeb4 100644
@@ -565,7 +565,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)
 		}
 
 		ret = snprintf(mz_name, sizeof(mz_name),
-			RTE_MEMPOOL_MZ_FORMAT "_%d", mp->name, mz_id);
+			"MC_%s_%u", mp->name, mz_id);
 		if (ret < 0 || ret >= (int)sizeof(mz_name)) {
 			ret = -ENAMETOOLONG;
 			goto fail;
Signature · 1 line
2.43.0