dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mbuf: optimize refcnt handling during free
@ 2015-03-26 18:10 Zoltan Kiss
       [not found] ` <1427393457-7080-1-git-send-email-zoltan.kiss-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Zoltan Kiss @ 2015-03-26 18:10 UTC (permalink / raw)
  To: dev-VfR2kkLFssw; +Cc: Zoltan Kiss

The current way is not the most efficient: if m->refcnt is 1, the second
condition never evaluates, and we set it to 0. If refcnt > 1, the 2nd
condition fails again, although the code suggest otherwise to branch
prediction. Instead we should keep the second condition only, and remove the
duplicate set to zero.

Signed-off-by: Zoltan Kiss <zoltan.kiss-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 lib/librte_mbuf/rte_mbuf.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 17ba791..3ec4024 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -764,10 +764,7 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
 {
 	__rte_mbuf_sanity_check(m, 0);
 
-	if (likely (rte_mbuf_refcnt_read(m) == 1) ||
-			likely (rte_mbuf_refcnt_update(m, -1) == 0)) {
-
-		rte_mbuf_refcnt_set(m, 0);
+	if (likely (rte_mbuf_refcnt_update(m, -1) == 0)) {
 
 		/* if this is an indirect mbuf, then
 		 *  - detach mbuf
-- 
1.9.1

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

end of thread, other threads:[~2015-03-27 13:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-26 18:10 [PATCH] mbuf: optimize refcnt handling during free Zoltan Kiss
     [not found] ` <1427393457-7080-1-git-send-email-zoltan.kiss-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-26 21:00   ` Wiles, Keith
     [not found]     ` <D139DD49.19B82%keith.wiles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-26 21:07       ` Bruce Richardson
2015-03-27 10:25       ` Neil Horman
     [not found]         ` <20150327102533.GA5375-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2015-03-27 10:48           ` Ananyev, Konstantin
     [not found]             ` <2601191342CEEE43887BDE71AB97725821407F18-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-03-27 12:44               ` Neil Horman
     [not found]                 ` <20150327124451.GE5375-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2015-03-27 13:10                   ` Olivier MATZ
     [not found]                     ` <551556C9.6030609-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2015-03-27 13:16                       ` Bruce Richardson
2015-03-27 13:22                         ` Ananyev, Konstantin
2015-03-27 10:50           ` Olivier MATZ

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