[dpdk-dev] [PATCH 15/15] mbuf: move pool pointer in hotterfirst half

Bruce Richardson bruce.richardson at intel.com
Thu Nov 5 11:29:56 CET 2020


On Thu, Nov 05, 2020 at 10:35:45AM +0100, Morten Brørup wrote:
> There is a simple alternative for applications with a single mbuf pool to avoid accessing m->pool.
> 
> We could add a global variable pointing to the single mbuf pool.
> 
> It would be NULL by default.
> 
> It would be set by rte_pktmbuf_pool_create() on first invocation, and reset back to NULL on following invocations. (There would need to be a counter too, to prevent setting it again on the third invocation.)
> 
> All functions accessing m->pool would use the global mbuf pool pointer if set, and otherwise use the m->pool pointer, like this:
> 
> - rte_mempool_put(m->pool, m);
> + rte_mempool_put(global_mbuf_pool ? global_mbuf_pool : m->pool, m);
> 
> This optimization can be implemented without ABI breakage:
> 
> Since m->pool is initialized as always, functions that are not modified to use the global_mbuf_pool will simply continue using m->pool, not knowing that a global mbuf pool exists.
> 
Very interesting idea. Definitely worth considering. A TX function would
only have to check the global variable once at the start of cleanup too,
and if set, it can use bulk frees without any additional work.

/Bruce


More information about the dev mailing list