DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mbuf: optimize first reference increment in rte_pktmbuf_attach
@ 2015-06-01  9:32 Olivier Matz
  2015-06-03 10:59 ` Bruce Richardson
  2015-06-08 14:57 ` [dpdk-dev] [PATCH v2] mbuf: optimize rte_mbuf_refcnt_update Olivier Matz
  0 siblings, 2 replies; 6+ messages in thread
From: Olivier Matz @ 2015-06-01  9:32 UTC (permalink / raw)
  To: dev

As it's done in __rte_pktmbuf_prefree_seg(), we can avoid using an
atomic increment in rte_pktmbuf_attach() by checking if we are the
only owner of the mbuf first.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_mbuf/rte_mbuf.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ab6de67..cea35b7 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -838,7 +838,11 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m)
 	else
 		md = rte_mbuf_from_indirect(m);
 
-	rte_mbuf_refcnt_update(md, 1);
+	/* optimize the case where we are the only owner */
+	if (likely(rte_mbuf_refcnt_read(md) == 1))
+		rte_mbuf_refcnt_set(md, 2);
+	else
+		rte_mbuf_refcnt_update(md, 1);
 	mi->priv_size = m->priv_size;
 	mi->buf_physaddr = m->buf_physaddr;
 	mi->buf_addr = m->buf_addr;
-- 
2.1.4

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

end of thread, other threads:[~2015-06-12 14:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01  9:32 [dpdk-dev] [PATCH] mbuf: optimize first reference increment in rte_pktmbuf_attach Olivier Matz
2015-06-03 10:59 ` Bruce Richardson
2015-06-05  9:07   ` Olivier MATZ
2015-06-08 14:57 ` [dpdk-dev] [PATCH v2] mbuf: optimize rte_mbuf_refcnt_update Olivier Matz
2015-06-09 12:57   ` Bruce Richardson
2015-06-12 14:10     ` Thomas Monjalon

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).