From: Zoltan Kiss <zoltan.kiss@linaro.org>
To: dev@dpdk.org
Cc: Zoltan Kiss <zoltan.kiss@linaro.org>
Subject: [dpdk-dev] [PATCH] mbuf: optimize refcnt handling during free
Date: Thu, 26 Mar 2015 18:10:57 +0000 [thread overview]
Message-ID: <1427393457-7080-1-git-send-email-zoltan.kiss@linaro.org> (raw)
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@linaro.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
next reply other threads:[~2015-03-26 18:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 18:10 Zoltan Kiss [this message]
2015-03-26 21:00 ` Wiles, Keith
2015-03-26 21:07 ` Bruce Richardson
2015-03-27 10:25 ` Neil Horman
2015-03-27 10:48 ` Ananyev, Konstantin
2015-03-27 12:44 ` Neil Horman
2015-03-27 13:10 ` Olivier MATZ
2015-03-27 13:16 ` Bruce Richardson
2015-03-27 13:22 ` Ananyev, Konstantin
2015-03-27 10:50 ` Olivier MATZ
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427393457-7080-1-git-send-email-zoltan.kiss@linaro.org \
--to=zoltan.kiss@linaro.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).