[dpdk-dev] [PATCH v2] mbuf: optimize rte_mbuf_refcnt_update

Bruce Richardson bruce.richardson at intel.com
Wed Jan 13 12:48:20 CET 2016

On Tue, Jan 05, 2016 at 11:11:24AM +0000, Hanoch Haim (hhaim) wrote:
> Hi Oliver, 
> Thank you for the fast response and it would be great to open a discussion on that.
> In general our project can leverage your optimization and I think it is great (we should have thought about it) . We can use it using the workaround I described.
> However, for me it  seems odd that  rte_pktmbuf_attach () that does not *change* anything in m_const, except of the *atomic* ref counter does not work in parallel.
> The example I gave is a classic use case of rte_pktmbuf_attach  (multicast ) and I don't see why it wouldn't work after your optimization. 
> Do you have a pointer to the documentation that state that that you can't call the atomic ref counter from more than one thread?

actually, the issue is not that you can't work with the reference counter field
from multiple threads, or that you can't use an mbuf from multiple threads,
it's that if you are working with the same mbuf in multiple threads you have
multiple references to the mbuf and your application must increase the reference
counter appropriately. For example, if thread A is going to pass an mbuf to
thread B and keep using it itself, you must increment the reference counter
in thread A before enqueuing it to B.


More information about the dev mailing list