Did you look at the Dynamic Mbuf Fields API?
You can reserve a large chunk as an mbuf dynamic field. It will be contiguous.
You can also specify alignment when allocating a field.
Maybe the size of the dynfield3 area should be run-time configurable; I addressed that option at the end of my original reply.
Unless there’s some subtle point I’m misunderstanding, I’m confident Dynamic Mbuf Fields is the right solution for your use case.
As the mbuf maintainer, I would welcome such an addition to the Dynamic Mbuf Fields library.
Venlig hilsen / Kind regards,
-Morten Brørup
From: Morten Brørup
Sent: Tuesday, 1 September 2026 18.23
To: 'Randy Tice (rtice)'; dev@dpdk.org; Stephen Hemminger; Konstantin Ananyev
Subject: RE: [RFC] mbuf: add configurable base private size for pktmbuf pools
Randy,
I don’t understand why you don’t like my proposed solution.
What is the difference between adding 384 bytes to all mbufs as an extra dynfield3, compared to adding 384 bytes to all mbufs through application_base_priv?
The extra 384 bytes will be located at the same position relative to the mbuf (between the rte_mbuf structure and the priv_data area), and will use the same amount of memory for all mbufs.
You propose splitting the priv_data area into two parts: One globally sized area for all mbuf pools (configured through the EAL option), and one per-mempool sized area, configured at pktmbuf-pool creation.
Then the global priv_data part does exactly the same the Dynamic Mbuf Fields does.
There is no reason to introduce another method for doing something an existing API already does.
It’s better to expand the implementation of the existing API.
Venlig hilsen / Kind regards,
-Morten Brørup
From: Randy Tice (rtice) [mailto:rtice@cisco.com]
Sent: Tuesday, 1 September 2026 17.44
To: Morten Brørup; dev@dpdk.org; Stephen Hemminger; Konstantin Ananyev
Subject: Re: [RFC] mbuf: add configurable base private size for pktmbuf pools
Morten,
Thanks for the detailed response. I went back through our requirements and the
current mbuf layout, and I believe our use case maps better to private data.
The metadata area we need today is roughly 384 bytes per mbuf. It needs to be
contiguous, cache-aligned, and available consistently across the packet mbuf
pools used by the platform.
The existing reserved areas in struct rte_mbuf do not fit that shape.
dynfield1[9] is only 36 bytes and is not cache-line aligned as a standalone
area. dynfield2 is only 8 bytes and is configuration-dependent: it exists only
when RTE_IOVA_IN_MBUF is 0, meaning the IOVA value is not carried in the mbuf.
When RTE_IOVA_IN_MBUF is 1, that mbuf slot is used for other layout state and
dynfield2 is absent. So even using those fields directly, they are not large
enough or consistent enough for this metadata overlay.
We could add a larger reserved area such as the proposed dynfield3, but it
would have to be size-adjustable. Not every application would want another
fixed 384 bytes in every mbuf, and our own requirement has already moved from
256 to 384 bytes for 64-bit applications, so the size may continue to evolve.
That makes a fixed mbuf-struct expansion a poor fit.
The existing private data area already exists for this kind of use case:
contiguous per-mbuf storage adjacent to the mbuf object, with sizing handled
as part of mbuf pool creation. The issue we are trying to solve is that
priv_size is currently pool-specific, while our common packet metadata needs a
base area available across all packet mbuf pools. The proposed patch adds that
common base private size through the standard packet mbuf pool creation
helpers. Pool-specific private data can still be added on top when needed.
So, for this use case, private data is the cleaner and more direct fit.
Thanks,
-rt