* [RFC] increase name sizes and reorder structures
@ 2026-08-13 17:12 Stephen Hemminger
2026-08-14 12:12 ` Morten Brørup
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2026-08-13 17:12 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, Morten Brørup, Anatoly Burakov,
Konstantin Ananyev, Wathsala Vithanage
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
Reported-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index c8cc86295d..4732e0ec72 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -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
------------
diff --git a/lib/eal/include/rte_memzone.h b/lib/eal/include/rte_memzone.h
index 5a0e1b8a15..5aef676e3b 100644
--- a/lib/eal/include/rte_memzone.h
+++ b/lib/eal/include/rte_memzone.h
@@ -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.
diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h
index 6cd6ce9884..cdd0ec4428 100644
--- a/lib/ring/rte_ring_core.h
+++ b/lib/ring/rte_ring_core.h
@@ -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 {
diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h
index fd17ac791d..0a74efad6c 100644
--- a/lib/stack/rte_stack.h
+++ b/lib/stack/rte_stack.h
@@ -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 */
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [RFC] increase name sizes and reorder structures
2026-08-13 17:12 [RFC] increase name sizes and reorder structures Stephen Hemminger
@ 2026-08-14 12:12 ` Morten Brørup
2026-08-14 15:19 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Morten Brørup @ 2026-08-14 12:12 UTC (permalink / raw)
To: Stephen Hemminger, dev
Cc: Anatoly Burakov, Konstantin Ananyev, Wathsala Vithanage
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> 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.
>
> Bugzilla ID: 1984
>
> Reported-by: Morten Brørup <mb@smartsharesystems.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
Not as much as I hoped for, but non-intrusive.
A small improvement is still an improvement!
Typo in the release notes:
"incre " -> "increased"
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] increase name sizes and reorder structures
2026-08-14 12:12 ` Morten Brørup
@ 2026-08-14 15:19 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-08-14 15:19 UTC (permalink / raw)
To: Morten Brørup
Cc: dev, Anatoly Burakov, Konstantin Ananyev, Wathsala Vithanage
On Fri, 14 Aug 2026 14:12:11 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > 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.
> >
> > Bugzilla ID: 1984
> >
> > Reported-by: Morten Brørup <mb@smartsharesystems.com>
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
>
> Not as much as I hoped for, but non-intrusive.
> A small improvement is still an improvement!
>
> Typo in the release notes:
> "incre " -> "increased"
>
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
>
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-14 15:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 17:12 [RFC] increase name sizes and reorder structures Stephen Hemminger
2026-08-14 12:12 ` Morten Brørup
2026-08-14 15:19 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.