> From: Bruce Richardson [mailto:bruce.richard...@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. ;-)