mempool name size incorrect?
Isn't the RTE_MEMPOOL_NAMESIZE too short?
Looking at the names sizes:
RTE_MEMZONE_NAMESIZE = 32,RTE_RING_NAMESIZE = RTE_MEMZONE_NAMESIZE - (sizeof("RG_")=4) + 1 = 29, RTE_MEMPOOL_NAMESIZE = RTE_RING_NAMESIZE - (sizeof("MP_")=4) + 1 = 26
Referring to [1], I think it should be fixed as:
- #define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
+ #define RTE_MEMPOOL_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
There is no ring involved, so I guess it is some kind of copy-paste-search-replace error.
Looking at the rte_mempool structure [2]:
struct __rte_cache_aligned rte_mempool {
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void *pool_data; /**< Ring or pool to store objects. */
uint64_t pool_id; /**< External mempool identifier. */
};
Due to the 8-byte alignment of the pool_id field following the name field, fixing the length as suggested doesn't change the memory layout for 64 bit CPU architectures. But it does for 32 bit CPU architectures, which will only 4-byte align the pool_id field.
[1]: https://elixir.bootlin.com/dpdk/v26.03-rc1/source/lib/mempool/rte_mempool.h#L128
[2]: https://elixir.bootlin.com/dpdk/v26.03-rc1/source/lib/mempool/rte_mempool.h#L230
Another thing:
On 32 bit CPU architectures, the cache_size and local_cache fields in the rte_mempool structure are not in the same cache line. But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 8 lines · Morten Brørup
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1 = 29,RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1 = 26
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-paste-search-replace error.
I guess ring is involved in fact since the default mempool driver is ring.
See drivers/mempool/ring/rte_mempool_ring.c ring_alloc().
Yes, it is not ideal, but at least it explains why RTE_RING_NAMESIZE is used.
Quoted 25 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to store objects. */
uint64_tpool_id; /**< External mempool identifier. */
};Due to the 8-byte alignment of the
pool_idfield following the name field, fixing the length as suggested doesn't change the memory layout for 64 bit CPU architectures. But it does for 32 bit CPU architectures, which will only 4-byte align thepool_idfield.[1]: https://elixir.bootlin.com/dpdk/v26.03-rc1/source/lib/mempool/rte_mempool.h#L128
[2]: https://elixir.bootlin.com/dpdk/v26.03-rc1/source/lib/mempool/rte_mempool.h#L230Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields in therte_mempoolstructure are not in the same cache line. But I guess we don't really care about 32 bit CPU architectures.Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 23 lines
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Wednesday, 11 March 2026 10.47Quoted 6 lines · Morten Brørup
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1 =29,
Quoted 9 lines
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1 = 26Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-paste-
search-replace error.
Quoted 1 line
Quoted 7 lines
I guess ring is involved in fact since the default mempool driver is ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEis used.
Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_" to the name of any memzone it creates.
Looking into the associated string length checks, using a too long name will fail with ENAMETOOLONG. So, using a long mempool name might succeed with some mempool drivers and fail with others. :-(
I guess there's no simple fix for that.
And I was wrong to think that the RTE_MEMPOOL_NAMESIZE should be increased from 26 to 29.
Quoted 34 lines
Quoted 7 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempool identifier.*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield following the namefield, fixing the length as suggested doesn't change the memory layout for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-byte
align the
pool_idfield.Quoted 2 lines
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields inthe
rte_mempoolstructure are not in the same cache line.Quoted 6 lines
But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 35 lines
Quoted 11 lines · Morten Brørup
Quoted 6 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1 =29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1 =26
Quoted 11 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-paste-
search-replace error.
Quoted 1 line
Quoted 7 lines
I guess ring is involved in fact since the default mempool driver is ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEis used.Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_" to the name of any memzone it creates.
Quoted 8 lines
Looking into the associated string length checks, using a too long name will fail with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempool drivers and fail with others. :-(I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.
As a generic thought: might be it is time to make the length across these structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.
Quoted 34 lines
Quoted 34 lines
Quoted 7 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempool identifier.*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield following the namefield, fixing the length as suggested doesn't change the memory layout for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-byte
align the
pool_idfield.Quoted 2 lines
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields inthe
rte_mempoolstructure are not in the same cache line.Quoted 6 lines
But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 40 lines · Konstantin Ananyev
Quoted 40 lines
Quoted 11 lines · Morten Brørup
Quoted 6 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1 =29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1 =26
Quoted 11 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-paste-
search-replace error.
Quoted 1 line
Quoted 7 lines
I guess ring is involved in fact since the default mempool driver is ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEis used.Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_" to the name of any memzone it creates.Looking into the associated string length checks, using a too long name will fail with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempool drivers and fail with others. :-(
Quoted 7 lines
Quoted 3 lines
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.As a generic thought: might be it is time to make the length across these structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.
Why not, if it is really required
Quoted 36 lines
Quoted 35 lines
Quoted 35 lines
Quoted 8 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempool identifier.*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield following the namefield, fixing the length as suggested doesn't change the memory layout for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-byte
align the
pool_idfield.Quoted 2 lines
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields inthe
rte_mempoolstructure are not in the same cache line.Quoted 6 lines
But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 49 lines
From: Konstantin Ananyev [mailto:[email protected]]
Sent: Wednesday, 11 March 2026 11.52Quoted 7 lines
Quoted 7 lines · Morten Brørup
Quoted 6 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1=
Quoted 2 lines
Quoted 2 lines
29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1=
Quoted 9 lines
26
Quoted 8 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-
paste-
Quoted 4 lines
Quoted 4 lines
search-replace error.
Quoted 1 line
I guess ring is involved in fact since the default mempool driver
is
Quoted 5 lines
Quoted 5 lines
ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEQuoted 4 lines
Quoted 1 line
is used.
Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_"to the
Quoted 3 lines
name of any memzone it creates.
Looking into the associated string length checks, using a too long
name will fail
Quoted 2 lines
with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempool driversand
Quoted 2 lines
fail with others. :-(
Quoted 8 lines
Quoted 3 lines
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.As a generic thought: might be it is time to make the length across these
structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.
I assume the names are allocated as part of the structures to make them part of the shared memory, to be searchable by secondary processes.
I guess someone once thought 32 characters would be enough.
Furthermore, these startup-only parts of the structures really should be clearly marked as such, to ensure that they remain in dedicated cache lines, not mixed with hot fields in the same structures.
As I mentioned below, when building for 32 bit architectures, the cache_size field - which is accessed by the mempool fastpath functions - is in a cache line shared with the name, instead of the cache line with the local_cache field pointing to the local cache; i.e. causing two cache misses instead of one, when getting or putting objects from/to a mempool cache.
I agree that this should be cleaned up at a future big API breakage.
Quoted 39 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempoolidentifier.
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield following thename
Quoted 1 line
Quoted 1 line
field, fixing the length as suggested doesn't change the memory
layout
Quoted 4 lines
Quoted 4 lines
for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-byte
align the
pool_idfield.Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields in
Quoted 7 lines
Quoted 7 lines
the
rte_mempoolstructure are not in the same cache line.Quoted 6 lines
But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1=
Quoted 2 lines
Quoted 2 lines
29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1=
Quoted 9 lines
26
Quoted 8 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-
paste-
Quoted 4 lines
Quoted 4 lines
search-replace error.
Quoted 1 line
I guess ring is involved in fact since the default mempool driver
is
Quoted 5 lines
Quoted 5 lines
ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEQuoted 4 lines
Quoted 1 line
is used.
Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_"to the
Quoted 3 lines
name of any memzone it creates.
Looking into the associated string length checks, using a too long
name will fail
Quoted 2 lines
with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempool driversand
Quoted 5 lines
fail with others. :-(
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.
Quoted 7 lines
Quoted 4 lines
As a generic thought: might be it is time to make the length across these
structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.I assume the names are allocated as part of the structures to make them part of the shared memory, to be searchable by secondary processes.
Yes sure, but we can put the actual name-buffer somewhere else:
let say for the ring at the very end (after the elements array) and store only a pointer to it in the rte_ring header.
I.E. at ring_create we check name-length - allocate extra 'name-length' bytes for it, initialize pointer to name with address of this extra bytes. Probably the same can be done with the mempool, etc.
Quoted 53 lines
I guess someone once thought 32 characters would be enough.
Furthermore, these startup-only parts of the structures really should be clearly marked as such, to ensure that they remain in dedicated cache lines, not mixed with hot fields in the same structures.
As I mentioned below, when building for 32 bit architectures, thecache_sizefield
- which is accessed by the mempool fastpath functions - is in a cache line shared with the name, instead of the cache line with thelocal_cachefield pointing to the local cache; i.e. causing two cache misses instead of one, when getting or putting objects from/to a mempool cache.I agree that this should be cleaned up at a future big API breakage.
Quoted 39 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempoolidentifier.
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield following thename
Quoted 1 line
Quoted 1 line
field, fixing the length as suggested doesn't change the memory
layout
Quoted 4 lines
Quoted 4 lines
for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-byte
align the
pool_idfield.Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields in
Quoted 7 lines
Quoted 7 lines
the
rte_mempoolstructure are not in the same cache line.Quoted 6 lines
But I guess we don't really care about 32 bit CPU architectures.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 65 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4)+ 1
Quoted 3 lines
Quoted 3 lines
=
Quoted 2 lines
Quoted 2 lines
29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4)+ 1
Quoted 10 lines
Quoted 10 lines
=
Quoted 9 lines
26
Quoted 8 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of
copy-
Quoted 5 lines
Quoted 5 lines
paste-
Quoted 4 lines
Quoted 4 lines
search-replace error.
Quoted 1 line
I guess ring is involved in fact since the default mempool
driver
Quoted 11 lines
Quoted 11 lines
is
Quoted 5 lines
Quoted 5 lines
ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEQuoted 4 lines
Quoted 1 line
is used.
Thanks, that explains it. Bad layer violation... Let's hope no future mempool driver adds anything longer than
"
RG_"Quoted 4 lines
Quoted 4 lines
to the
Quoted 3 lines
name of any memzone it creates.
Looking into the associated string length checks, using a too
long
Quoted 3 lines
Quoted 3 lines
name will fail
Quoted 2 lines
with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempooldrivers
Quoted 7 lines
Quoted 7 lines
and
Quoted 5 lines
fail with others. :-(
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.Quoted 6 lines
Quoted 4 lines
As a generic thought: might be it is time to make the length across these
structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.I assume the names are allocated as part of the structures to make
them part of
Quoted 1 line
the shared memory, to be searchable by secondary processes.
Quoted 7 lines
Yes sure, but we can put the actual name-buffer somewhere else:
let say for the ring at the very end (after the elements array) and store only a pointer to it in therte_ringheader.
I.E. atring_createwe check name-length - allocate extra 'name-length' bytes for it, initialize pointer to name with address of this extra bytes.
Probably the same can be done with the mempool, etc.
Could be done, yes.
Another reason for having the names first in the structures might be for debugging, e.g. when looking at raw memory.
Supporting arbitrary name lengths is probably not worth the effort.
But 31 characters seems somewhat short to me.
E.g. I have one named "RG_HT_ethertype_0000:01:00.0", 28 characters, which seems to be created by a driver. So we could extend them to 63 characters. "Should be enough for anyone" - famous last words. ;-)
Quoted 63 lines
Quoted 5 lines
I guess someone once thought 32 characters would be enough.
Furthermore, these startup-only parts of the structures really should
be clearly
Quoted 1 line
marked as such, to ensure that they remain in dedicated cache lines,
not mixed
Quoted 2 lines
with hot fields in the same structures.
As I mentioned below, when building for 32 bit architectures, the
cache_sizefieldQuoted 1 line
- which is accessed by the mempool fastpath functions - is in a cache
line shared
Quoted 1 line
with the name, instead of the cache line with the
local_cachefieldpointing to the
Quoted 1 line
local cache; i.e. causing two cache misses instead of one, when
getting or putting
Quoted 20 lines
objects from/to a mempool cache.
I agree that this should be cleaned up at a future big API breakage.
Quoted 16 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union {
void*pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempoolidentifier.
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield followingthe
Quoted 5 lines
Quoted 5 lines
name
Quoted 1 line
Quoted 1 line
field, fixing the length as suggested doesn't change the memory
layout
Quoted 2 lines
Quoted 2 lines
for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-
byte
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
align the
pool_idfield.Quoted 2 lines
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields in
Quoted 2 lines
Quoted 2 lines
the
rte_mempoolstructure are not in the same cache line.Quoted 1 line
But I guess we don't really care about 32 bit CPU
architectures.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 75 lines
Quoted 67 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4)+ 1
Quoted 3 lines
Quoted 3 lines
=
Quoted 2 lines
Quoted 2 lines
29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4)+ 1
Quoted 10 lines
Quoted 10 lines
=
Quoted 9 lines
26
Quoted 8 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of
copy-
Quoted 5 lines
Quoted 5 lines
paste-
Quoted 4 lines
Quoted 4 lines
search-replace error.
Quoted 1 line
I guess ring is involved in fact since the default mempool
driver
Quoted 11 lines
Quoted 11 lines
is
Quoted 5 lines
Quoted 5 lines
ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEQuoted 4 lines
Quoted 1 line
is used.
Thanks, that explains it. Bad layer violation... Let's hope no future mempool driver adds anything longer than
"
RG_"Quoted 4 lines
Quoted 4 lines
to the
Quoted 3 lines
name of any memzone it creates.
Looking into the associated string length checks, using a too
long
Quoted 3 lines
Quoted 3 lines
name will fail
Quoted 2 lines
with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempooldrivers
Quoted 7 lines
Quoted 7 lines
and
Quoted 5 lines
fail with others. :-(
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.Quoted 6 lines
Quoted 4 lines
As a generic thought: might be it is time to make the length across these
structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.I assume the names are allocated as part of the structures to make
them part of
Quoted 1 line
the shared memory, to be searchable by secondary processes.
Quoted 7 lines
Yes sure, but we can put the actual name-buffer somewhere else:
let say for the ring at the very end (after the elements array) and store only a pointer to it in therte_ringheader.
I.E. atring_createwe check name-length - allocate extra 'name-length' bytes for it, initialize pointer to name with address of this extra bytes.
Probably the same can be done with the mempool, etc.
Quoted 4 lines
Could be done, yes.
Another reason for having the names first in the structures might be for debugging, e.g. when looking at raw memory.
I can hardly imagine how doing extra dereference will become a real problem for some debugging scripts.
Quoted 6 lines
Supporting arbitrary name lengths is probably not worth the effort. But 31 characters seems somewhat short to me.
E.g. I have one named "RG_HT_ethertype_0000:01:00.0", 28 characters, which seems to be created by a driver.
So we could extend them to 63 characters. "Should be enough for anyone" - famous last words. ;-)
I'd rather make it arbitrary, or simply not touch at all ;)
Quoted 64 lines
Quoted 10 lines
Quoted 5 lines
I guess someone once thought 32 characters would be enough.
Furthermore, these startup-only parts of the structures really should
be clearly
Quoted 1 line
marked as such, to ensure that they remain in dedicated cache lines,
not mixed
Quoted 2 lines
with hot fields in the same structures.
As I mentioned below, when building for 32 bit architectures, theQuoted 17 lines
cache_sizefieldQuoted 1 line
- which is accessed by the mempool fastpath functions - is in a cache
line shared
Quoted 1 line
with the name, instead of the cache line with the
local_cachefieldpointing to the
Quoted 1 line
local cache; i.e. causing two cache misses instead of one, when
getting or putting
Quoted 10 lines
objects from/to a mempool cache.
I agree that this should be cleaned up at a future big API breakage.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Looking at the
rte_mempoolstructure [2]:
struct__rte_cache_alignedrte_mempool{
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool.*/
Quoted 36 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
union { void *pool_data; /**< Ring or pool to storeobjects. */
Quoted 1 line
uint64_tpool_id; /**< External mempoolidentifier.
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
};Due to the 8-byte alignment of the
pool_idfield followingthe
Quoted 5 lines
Quoted 5 lines
name
Quoted 1 line
Quoted 1 line
field, fixing the length as suggested doesn't change the memory
layout
Quoted 2 lines
Quoted 2 lines
for 64 bit CPU architectures.
Quoted 1 line
But it does for 32 bit CPU architectures, which will only 4-
byte
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
align the
pool_idfield.Quoted 2 lines
rc1/source/lib/mempool/rte_mempool.h#L128
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
rc1/source/lib/mempool/rte_mempool.h#L230
Quoted 4 lines
Another thing:
On 32 bit CPU architectures, thecache_sizeandlocal_cachefields in
Quoted 2 lines
Quoted 2 lines
the
rte_mempoolstructure are not in the same cache line.Quoted 1 line
But I guess we don't really care about 32 bit CPU
architectures.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 38 lines · On Wed, 11 Mar 2026 10:52:11 +0000 Konstantin Ananyev…
Quoted 38 lines
Quoted 9 lines · Morten Brørup
Quoted 6 lines
Isn't the
RTE_MEMPOOL_NAMESIZEtoo short?Looking at the names sizes:
RTE_MEMZONE_NAMESIZE= 32,RTE_RING_NAMESIZE=RTE_MEMZONE_NAMESIZE- (sizeof("RG_")=4) + 1 =29,
Quoted 1 line
RTE_MEMPOOL_NAMESIZE=RTE_RING_NAMESIZE- (sizeof("MP_")=4) + 1 =26
Quoted 11 lines
Quoted 8 lines
Referring to [1], I think it should be fixed as:
- #defineRTE_MEMPOOL_NAMESIZE(RTE_RING_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)
+ #defineRTE_MEMPOOL_NAMESIZE(RTE_MEMZONE_NAMESIZE- \
sizeof(RTE_MEMPOOL_MZ_PREFIX)+ 1)There is no ring involved, so I guess it is some kind of copy-paste-
search-replace error.
Quoted 1 line
Quoted 7 lines
I guess ring is involved in fact since the default mempool driver is ring.
See
drivers/mempool/ring/rte_mempool_ring.cring_alloc().Yes, it is not ideal, but at least it explains why
RTE_RING_NAMESIZEis used.Thanks, that explains it. Bad layer violation...
Let's hope no future mempool driver adds anything longer than "RG_" to the name of any memzone it creates.Looking into the associated string length checks, using a too long name will fail with ENAMETOOLONG.
So, using a long mempool name might succeed with some mempool drivers and fail with others. :-(
Quoted 7 lines
Quoted 3 lines
I guess there's no simple fix for that.
And I was wrong to think that theRTE_MEMPOOL_NAMESIZEshould be increased from 26 to 29.As a generic thought: might be it is time to make the length across these structs (mempool, ring, etc.) arbitrary?
At our next big API breakage or so.
It would be good to switch to flexible array for these structures. Put name[] at end of struct.
Might want to have a sanity check of really misuse like 1K or something