<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I don’t disagree with you Konstantin, I will defer a decision until we hear back from Morten. It was also another consideration I had when I started with the privdata layout.</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-rt</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div style="padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor;">
<div style="text-align: left; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>Konstantin Ananyev <konstantin.ananyev@huawei.com><br>
<b>Date: </b>Tuesday, September 1, 2026 at 1:09 PM<br>
<b>To: </b>Morten Brørup <mb@smartsharesystems.com>; Randy Tice (rtice) <rtice@cisco.com>; dev@dpdk.org <dev@dpdk.org>; Stephen Hemminger <stephen@networkplumber.org><br>
<b>Subject: </b>RE: [RFC] mbuf: add configurable base private size for pktmbuf pools<br>
<br>
</div>
</div>
<div id="mail-editor-reference-message-body">
<div class="ms-outlook-mobile-reference-message skipProofing">
<meta name="Generator" content="Microsoft Exchange Server">
</div>
<div class="PlainText" style="font-size: 11pt;"><br>
> > Hi,<br>
> > I would like to get feedback on a proposed mbuf change before sending<br>
> patches.<br>
> > Some deployments need a guaranteed private-data reservation in every packet<br>
> mbuf, across multiple mbuf pools and across different consumers of the mbuf<br>
> APIs.<br>
> > Today, each pktmbuf pool can request a private size when the pool is created.<br>
> That works when the application owns all pool creation policy directly. However,<br>
> not all relevant mbuf pools are necessarily created by application code. Some<br>
> pools may be created by libraries, drivers, or other components outside direct<br>
> application control.<br>
> > One example already in DPDK is vhost crypto, which creates its own mbuf pool<br>
> and supplies a private size for struct vhost_crypto_data_req. There are also<br>
> driver-created pktmbuf-style pools, such as cnxk inline meta pools and TAP GSO<br>
> context pools. These are examples of pool-creation paths where the application<br>
> may not directly control the private-size value used at creation time.<br>
> > A PMD-specific devarg could solve one instance of this problem, such as a single<br>
> driver-created pool, but that seems too narrow if the requirement is not<br>
> inherently PMD-specific. A deployment with multiple drivers, libraries, or other<br>
> pool-creation paths outside application control could need the same base<br>
> private-size adjustment. In that case, configuring the same value independently<br>
> through component-specific options would be fragile and easy to get wrong.<br>
> > The proposed generic model is to add a configurable base private size for<br>
> pktmbuf pools. The effective private size would be:<br>
> > align(pool_requested_priv_size + application_base_priv_size,<br>
> >       RTE_MBUF_PRIV_ALIGN)<br>
> > The tentative EAL option name is:<br>
> > --mbuf-base-priv-size=<size><br>
> > The intent is:<br>
> > * default behavior remains unchanged when the option is not used;<br>
> > * the configured base size is added to the private size requested by each<br>
> pktmbuf pool;<br>
> > * the final effective private size remains aligned to RTE_MBUF_PRIV_ALIGN;<br>
> > * pool-specific private-data requests still work as they do today;<br>
> > * DPDK centralizes the policy so pools created outside application control can<br>
> reserve the same base private-data space as application-created pools.<br>
> > This is not intended to define ownership or layout of the private area. It only<br>
> ensures that a deployment can reserve a common base amount of private data<br>
> consistently. Applications, drivers, libraries, or components would still be<br>
> responsible for their own interpretation of the reserved private area.<br>
> > Questions for the list:<br>
> > 1. Is a deployment-wide pktmbuf base private-size reservation something DPDK<br>
> would consider acceptable?<br>
> > 2. Is --mbuf-base-priv-size=<size> a reasonable name, or would another name<br>
> better describe the intent?<br>
> > 3. Should DPDK expose the effective-size calculation as a helper so pool-<br>
> creation paths outside application control can apply the same rule?<br>
> > 4. Would maintainers prefer consumer updates in the same series as example<br>
> users, or as follow-up patches after the generic mbuf/EAL change is accepted?<br>
> > 5. Would maintainers prefer this to remain component-specific, even if more<br>
> than one driver, library, or pool-creation path may need to apply the same base<br>
> reservation?<br>
> > The main goal is to avoid downstream mbuf layout changes and avoid<br>
> component-specific configuration drift, while still allowing deployments to<br>
> reserve a consistent private-data area across all packet mbuf pools, including<br>
> pools created outside direct application control.<br>
> > Thanks,<br>
> > Randy<br>
><br>
> DPDK already has Dynamic Mbuf Fields for run-time management of private data<br>
> across all mbuf pools.<br>
> DPDK also has the Private Data Area (priv_size), but that is individual to each<br>
> mbuf pool, which does not fit your use case.<br>
><br>
> Dynamic Mbuf Fields is the perfect fit for the use case you are describing.<br>
><br>
> Currently, it only manages a few small memory areas inside the rte_mbuf<br>
> structure itself, the dynfield1 array and the dynfield2 field.<br>
> But it could easily manage one more memory area associated with the rte_mbuf<br>
> structure.<br>
><br>
> If we want this to be build-time configurable, it should be relatively simple to<br>
> add:<br>
><br>
> In config/rte_common.h:<br>
> +#define RTE_MBUF_DYN_EXTRA_SIZE 128<br>
><br>
> In lib/mbuf/rte_mbuf_core.h:<br>
>        /** Size of the application private data. In case of an indirect<br>
>         * mbuf, it stores the direct mbuf private data size.<br>
>         */<br>
>        uint16_t priv_size;<br>
><br>
>        /** Timesync flags for use with IEEE1588. */<br>
>        uint16_t timesync;<br>
><br>
>        uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */<br>
> +<br>
> +#if RTE_MBUF_DYN_EXTRA_SIZE<br>
> +     /** Extra dynamic fields. */<br>
> +     uint32_t dynfield3[RTE_MBUF_DYN_EXTRA_SIZE / sizeof(uint32_t)];<br>
> +#endif<br>
> };<br>
<br>
Please don't.<br>
Lets keep core mbuf size with constant size and layout.<br>
<br>
> In lib/mbuf/rte_mbuf_dyn.h:<br>
> +static_assert(RTE_MBUF_DYN_EXTRA_SIZE % RTE_CACHE_LINE_SIZE == 0,<br>
> +     "RTE_MBUF_DYN_EXTRA_SIZE must be multiple of cache line size.");<br>
><br>
> And some associated additions in lib/mbuf/rte_mbuf_dyn.c.<br>
><br>
> <feature creep><br>
><br>
> There may also be considerations about what happens to the extra data when:<br>
> - Copying an mbuf.<br>
> - Attaching an mbuf to another mbuf.<br>
> - Detaching an mbuf from another mbuf.<br>
> - Cloning an mbuf.<br>
><br>
> (The considerations apply to both the packet mbuf itself, and for the non-first<br>
> segments of a segmented packet mbuf.)<br>
><br>
> The developer of the Dynamic Mbuf Fields library was foreseeable enough to add<br>
> a "flags" parameter for dynamic mbuf field creation.<br>
> This could be used to specify what happens to each registered dynamic field in<br>
> the events enumerated above.<br>
><br>
> </feature creep><br>
><br>
> IMO, the extended size of Dynamic Mbuf Fields should be build-time<br>
> configurable.<br>
><br>
> If the community wants the extended size of Dynamic Mbuf Fields run-time<br>
> configurable, the size should be an EAL startup parameter.<br>
> It could be named: --mbuf-dyn-extra-size=<size>.<br>
> The major difference in implementation is that the space for the extra dynfields<br>
> must be dynamically allocated with the mbufs at mbuf pool creation.<br>
> Notice that the memory for the extra dynfields should be positioned between the<br>
> mbuf structure and the private data area, so their offsets remain the same, also<br>
> for two mbuf pools having different Private Data Area sizes.<br>
><br>
> -Morten<br>
<br>
</div>
</div>
</div>
</body>
</html>