From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 696245A7B for ; Thu, 26 Mar 2015 22:07:54 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 26 Mar 2015 14:07:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,474,1422950400"; d="scan'208";a="704782541" Received: from elewis-mobl1.ger.corp.intel.com ([10.252.3.24]) by orsmga002.jf.intel.com with SMTP; 26 Mar 2015 14:07:50 -0700 Received: by (sSMTP sendmail emulation); Thu, 26 Mar 2015 21:07:48 +0025 Date: Thu, 26 Mar 2015 21:07:48 +0000 From: Bruce Richardson To: "Wiles, Keith" Message-ID: <20150326210748.GA8640@bricha3-MOBL3> References: <1427393457-7080-1-git-send-email-zoltan.kiss@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "dev@dpdk.org" , Zoltan Kiss Subject: Re: [dpdk-dev] [PATCH] mbuf: optimize refcnt handling during free X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2015 21:07:54 -0000 On Thu, Mar 26, 2015 at 09:00:33PM +0000, Wiles, Keith wrote: > > > On 3/26/15, 1:10 PM, "Zoltan Kiss" 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 > >--- > > 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 Looks like a code comment that really, really needs to be added to the code itself! /Bruce > >-- > >1.9.1 > > >