DPDK patches and discussions
 help / color / mirror / Atom feed
* mbuf init questions
@ 2023-12-05  9:07 Morten Brørup
  2023-12-05  9:56 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Morten Brørup @ 2023-12-05  9:07 UTC (permalink / raw)
  To: dev

Why is m->nb_segs initialized in rte_pktmbuf_prefree_seg()?

It's part of the m->rearm_data, and will be initialized on RX descriptor rearm anyway.


Slightly related:

When built without RTE_IOVA_IN_MBUF, m->next lives in the first cache line.

Theoretically, it would improve performance to initialize m->next together with the RX descriptor rearm, when writing to the first cache line anyway, instead of in rte_pktmbuf_prefree_seg(), which requires another write to the first cache line. (In the case where m->next is non-NULL and m->refcnt is 1.)



Med venlig hilsen / Kind regards,
-Morten Brørup



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mbuf init questions
  2023-12-05  9:07 mbuf init questions Morten Brørup
@ 2023-12-05  9:56 ` Bruce Richardson
  2023-12-05 10:10   ` Morten Brørup
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2023-12-05  9:56 UTC (permalink / raw)
  To: Morten Brørup; +Cc: dev

On Tue, Dec 05, 2023 at 10:07:56AM +0100, Morten Brørup wrote:
> Why is m->nb_segs initialized in rte_pktmbuf_prefree_seg()?
> 
> It's part of the m->rearm_data, and will be initialized on RX descriptor rearm anyway.
> 
Presumably this is to have a sane default for apps that allocate buffers
directly using mempool_get functions.

Overall, we probably need to document clearly for mbufs allocated using
mempool apis rather than mbuf_alloc what fields are valid and what need to
be initialized.

/Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: mbuf init questions
  2023-12-05  9:56 ` Bruce Richardson
@ 2023-12-05 10:10   ` Morten Brørup
  0 siblings, 0 replies; 3+ messages in thread
From: Morten Brørup @ 2023-12-05 10:10 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Tuesday, 5 December 2023 10.56
> 
> On Tue, Dec 05, 2023 at 10:07:56AM +0100, Morten Brørup wrote:
> > Why is m->nb_segs initialized in rte_pktmbuf_prefree_seg()?
> >
> > It's part of the m->rearm_data, and will be initialized on RX
> descriptor rearm anyway.
> >
> Presumably this is to have a sane default for apps that allocate
> buffers
> directly using mempool_get functions.

Ahh, yes... the great bypassing of the mbuf APIs!

> 
> Overall, we probably need to document clearly for mbufs allocated using
> mempool apis rather than mbuf_alloc what fields are valid and what need
> to
> be initialized.

Good point. Since it has become customary - and generally accepted practice - to bypass the mbuf APIs and use the mempool APIs directly, we should document how to use the mempool APIs in an mbuf API context.

Spaghetti code, but everyone loves the performance benefits by doing it. Including myself. ;-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-05 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-05  9:07 mbuf init questions Morten Brørup
2023-12-05  9:56 ` Bruce Richardson
2023-12-05 10:10   ` Morten Brørup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).