Skip to contentSkip to conversation

increase name sizes and reorder structures

RFC In review Stephen Hemminger 2 participants 4 messages Aug 13 – Aug 20

lore
Share & tools
lore
#0 lore raw

RFC 1/1 increase name sizes and reorder structures

This is a trial balloon to see what Morten's suggestion would look like.

Increase memzone name size to 64 and reorder structure to keep it cache friendly. Move the zone name to the end of struct rte_memzone and order the remaining members by size. The structure is then naturally aligned
with no internal padding on both 64-bit and 32-bit targets, so the __rte_packed_begin/end markers can be removed.

With memzone size of 64 but don't need all that for stack names. Increase the size to 32 which adds some space without impacting cache layout.

The memzone increase to 64 allows ring names to grow to 32 characters. Don't need to go larger which could cause cache changes when ring is embedded in structures.

Bugzilla ID: 1984

---
 doc/guides/rel_notes/release_26_11.rst | 15 +++++++++++++++
 lib/eal/include/rte_memzone.h          | 15 ++++++---------
 lib/ring/rte_ring_core.h               |  7 +++++--
 lib/stack/rte_stack.h                  |  6 ++++--
 4 files changed, 30 insertions(+), 13 deletions(-)
doc/guides/rel_notes/release_26_11.rst +15 -0
index c8cc86295d..4732e0ec72 100644
@@ -93,6 +93,15 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* **Increased maximum name sizes.**
+
+  * memzone: The maximum length of a memory zone name ``RTE_MEMZONE_NAMESIZE``
+    was increased from 32 to 64.
+  * mempool: The maximum length of a mempool name ``RTE_MEMPOOL_NAMESIZE`` incre    from 26 to 29.
+  * ring: The maximum length of a ring name ``RTE_RING_NAMESIZE`` was increased from 29 to 32.
+  * stack: The maximum length of a stack name ``RTE_STACK_NAMESIZE`` was increased from 28 to 32.
+  * rcu: The maximum length of a defer queue name ``RTE_RCU_QSBR_DQ_NAMESIZE`` increased from 29 to 32.
+
 
 ABI Changes
 -----------
@@ -109,6 +118,12 @@ ABI Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* **Increased size of names in structures.**
+
+  * memzone: Moved the zone name to the end of ``rte_memzone``
+    and expanded to 64 bytes. Other names in``rte_ring``,
+    ``rte_stack``, ``rte_mempool`` and ``rcu_dq_name`` also increased.
+
 
 Known Issues
 ------------
lib/eal/include/rte_memzone.h +6 -9
index 5a0e1b8a15..5aef676e3b 100644
@@ -45,24 +45,21 @@ extern "C" {
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
-struct __rte_packed_begin rte_memzone {
-
-#define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
-	char name[RTE_MEMZONE_NAMESIZE];  /**< Name of the memory zone. */
-
+struct rte_memzone {
 	rte_iova_t iova;                  /**< Start IO address. */
 	union {
 		void *addr;                   /**< Start virtual address. */
 		uint64_t addr_64;             /**< Makes sure addr is always 64-bits */
 	};
-	size_t len;                       /**< Length of the memzone. */
-
 	uint64_t hugepage_sz;             /**< The page size of underlying memory */
+	size_t len;                       /**< Length of the memzone. */
 
 	int32_t socket_id;                /**< NUMA socket ID. */
-
 	uint32_t flags;                   /**< Characteristics of this memzone. */
-} __rte_packed_end;
+
+#define RTE_MEMZONE_NAMESIZE 64           /**< Maximum length of memory zone name.*/
+	char name[RTE_MEMZONE_NAMESIZE];  /**< Name of the memory zone. */
+};
 
 /**
  * Set the maximum number of memzones.
lib/ring/rte_ring_core.h +5 -2
index 6cd6ce9884..cdd0ec4428 100644
@@ -19,6 +19,7 @@
  * instead.
  */
 
+#include <assert.h>
 #include <stdalign.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -46,8 +47,10 @@ enum rte_ring_queue_behavior {
 
 #define RTE_RING_MZ_PREFIX "RG_"
 /** The maximum length of a ring name. */
-#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
-			   sizeof(RTE_RING_MZ_PREFIX) + 1)
+#define RTE_RING_NAMESIZE 32
+
+static_assert(RTE_RING_NAMESIZE <= RTE_MEMZONE_NAMESIZE - sizeof(RTE_RING_MZ_PREFIX) + 1,
+	      "rte_ring name size needs to fit in memzone with 3 character prefix");
 
 /** prod/cons sync types */
 enum rte_ring_sync_type {
lib/stack/rte_stack.h +4 -2
index fd17ac791d..0a74efad6c 100644
@@ -15,6 +15,7 @@
 #ifndef _RTE_STACK_H_
 #define _RTE_STACK_H_
 
+#include <assert.h>
 #include <stdalign.h>
 
 #include <rte_debug.h>
@@ -25,8 +26,9 @@
 #define RTE_TAILQ_STACK_NAME "RTE_STACK"
 #define RTE_STACK_MZ_PREFIX "STK_"
 /** The maximum length of a stack name. */
-#define RTE_STACK_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
-			   sizeof(RTE_STACK_MZ_PREFIX) + 1)
+#define RTE_STACK_NAMESIZE 32
+static_assert(RTE_STACK_NAMESIZE <= RTE_MEMZONE_NAMESIZE - sizeof(RTE_STACK_MZ_PREFIX) + 1,
+	      "rte_stack name size needs to fit in memzone with 4 character prefix");
 
 struct rte_stack_lf_elem {
 	void *data;			/**< Data pointer */
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines

From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 August 2026 19.13

This is a trial balloon to see what Morten's suggestion would look like.

Increase memzone name size to 64 and reorder structure to keep it cache friendly. Move the zone name to the end of struct rte_memzone and order the remaining members by size. The structure is then naturally aligned
with no internal padding on both 64-bit and 32-bit targets, so the __rte_packed_begin/end markers can be removed.

With memzone size of 64 but don't need all that for stack names. Increase the size to 32 which adds some space without impacting cache layout.

The memzone increase to 64 allows ring names to grow to 32 characters. Don't need to go larger which could cause cache changes when ring is embedded in structures.

Quoted 5 lines

Bugzilla ID: 1984

---

Not as much as I hoped for, but non-intrusive.
A small improvement is still an improvement!

Typo in the release notes:
"incre " -> "increased"

#2 lore raw
Quoted 27 lines · On Fri, 14 Aug 2026 14:12:11 +0200 Morten Brørup <[email protected]>…
Quoted 21 lines

From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 13 August 2026 19.13

This is a trial balloon to see what Morten's suggestion would look like.

Increase memzone name size to 64 and reorder structure to keep it cache friendly. Move the zone name to the end of struct rte_memzone and order the remaining members by size. The structure is then naturally aligned
with no internal padding on both 64-bit and 32-bit targets, so the __rte_packed_begin/end markers can be removed.

With memzone size of 64 but don't need all that for stack names. Increase the size to 32 which adds some space without impacting cache layout.

The memzone increase to 64 allows ring names to grow to 32 characters. Don't need to go larger which could cause cache changes when ring is embedded in structures.

Quoted 5 lines

Bugzilla ID: 1984

---

Quoted 8 lines

Not as much as I hoped for, but non-intrusive.
A small improvement is still an improvement!

Typo in the release notes:
"incre " -> "increased"

Only took baby first steps here. I asked AI for analysis on going further.

On the question of going bigger than 64/32, here is what I found looking at the actual constraints in the tree.

The memzone derivation is the artificial coupling
-------------------------------------------------

rte_ring_lookup(), rte_mempool_lookup() and rte_stack_lookup() all walk their tailq and strncmp() against the object's own name field. None of them go through rte_memzone_lookup(). So RTE_MEMZONE_NAMESIZE does not bound anything functional; it only bounds the derived string "RG_%s" used to reserve the backing memzone, which is a debug label plus a uniqueness token.

If the derived name became something like

	"RG_%.16s_%08x"   /* truncated prefix + hash of full name */

then RTE_RING_NAMESIZE, RTE_STACK_NAMESIZE and RTE_MEMPOOL_NAMESIZE are decoupled from memzone entirely and both static_asserts go away. Each library's limit then becomes a storage-cost decision rather than an inherited one.

Two things need handling:

- Hash collisions make rte_memzone_reserve() fail with EEXIST, so the reserve path needs a retry with a disambiguating counter.
- memzone dumps and telemetry output get less greppable. Keeping a truncated prefix of the real name mostly covers this.

Self-relative offset instead of a flexible array
------------------------------------------------

Two of the blockers (embedded structures, structures that already have a flexible array) exist only because C requires a flexible array to be last. An offset has no position requirement:

uint32_t name_off; /* byte offset from struct start to name */

This works when the struct is embedded (rte_event_ring wraps rte_ring), coexists with an existing trailing flexible array (rte_node_register is the case: name[RTE_NODE_NAMESIZE] plus next_nodes[]), and keeps the record fixed size so fbarray stride is preserved.

A plain const char * would probably also work since rte_mempool already stores a const struct rte_memzone *mz into shared memory, but an offset avoids depending on identical secondary process mappings.

Cost is source churn: every mz->name becomes rte_memzone_name(mz). Only 28 sites in tree, but out-of-tree consumers exist, so this wants a deprecation notice ahead of an ABI break release.

Side table (least disruptive)
-----------------------------

Keep the inline char name[N] untouched for compatibility and add a shared registry keyed by object index holding the full name only when it exceeds N. Lookup checks inline first, then the registry.

No stride change, no ABI change, no flexible arrays, unlimited length. The tradeoff is that mz->name and r->name stay truncated for anything reading them directly, so it fixes lookup but not display.

Numbers on ring growth
----------------------

Measured on x86-64:

	RTE_RING_NAMESIZE=32   sizeof(struct rte_ring)=384  prod at 128
	RTE_RING_NAMESIZE=61   sizeof(struct rte_ring)=448  prod at 192

One extra cache line per ring plus a shifted hot region, inherited by rte_event_ring. That is the concrete argument for capping ring names at 32 rather than following memzone to 64.

memzone is the opposite case: 104 bytes x 2560 default entries is about 266KB, so a larger fixed name there is nearly free. The fbarray stride constraint blocks variable-length names, not bigger ones.

#3 lore raw
In reply to Stephen Hemminger

Anurag raised an interesting question regarding Bug 1980 [1], which got me thinking...

Now that the max mempool name length has increased by three bytes, it is safe to reduce by one byte without breaking existing applications using long mempool names.

How about adding a modification of rte_mempool.h [2] like this (untested), to fix Bug 1980 (at least for stack drivers):

-/**< Maximum length of a memory pool's name. */ -#define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
- sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)

+/**
+ * Maximum length of a memory pool's name.
+ *
+ * Needs room for memzone prefix indicating "mempool" type:
+ * "MP_<name>"
+ * Note:
+ * The mempool driver needs room for its own memzone prefix too, e.g.:
+ * "RG_MP_<name>" (ring driver) or "STK_MP_<name>" (stack driver)
+ * In order to fail early on too long names when creating the mempool,
+ * the length of the memzone name reserved by various mempool drivers are
+ * not considered; only the ring and stack drivers are considered here.
+ * If the name eventually turns out to be too long for the chosen mempool driver,
+ * populating the mempool will fail.
+ */
+#define RTE_MEMPOOL_OPS_REPRESENTATIVE_NAMESIZE \
+ RTE_MAX(RTE_RING_NAMESIZE, RTE_STACK_NAMESIZE)
+#define RTE_MEMPOOL_NAMESIZE \
+ (RTE_MEMPOOL_OPS_REPRESENTATIVE_NAMESIZE - \
+ (sizeof(RTE_MEMPOOL_MZ_PREFIX) - 1))

[1]: https://bugs.dpdk.org/show_bug.cgi?id=1980
[2]: https://elixir.bootlin.com/dpdk/v26.07/source/lib/mempool/rte_mempool.h#L130

Then, the release notes should be updated too:
- * mempool: The maximum length of a mempool name ``RTE_MEMPOOL_NAMESIZE`` increased from 26 to 29.
- * mempool: The maximum length of a mempool name ``RTE_MEMPOOL_NAMESIZE`` increased from 26 to 28.