[dpdk-dev] [PATCH] mbuf: optimize refcnt handling during free

Wiles, Keith keith.wiles at intel.com
Thu Mar 26 22:00:33 CET 2015



On 3/26/15, 1:10 PM, "Zoltan Kiss" <zoltan.kiss at linaro.org> wrote:

>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 at 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

I fell for this one too, but read Bruce¹s email
http://dpdk.org/ml/archives/dev/2015-March/014481.html
>-- 
>1.9.1
>



More information about the dev mailing list