From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH] mbuf: optimize refcnt handling during free Date: Thu, 26 Mar 2015 21:07:48 +0000 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-Transfer-Encoding: quoted-printable Cc: "dev-VfR2kkLFssw@public.gmane.org" , Zoltan Kiss To: "Wiles, Keith" Return-path: Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" On Thu, Mar 26, 2015 at 09:00:33PM +0000, Wiles, Keith wrote: >=20 >=20 > On 3/26/15, 1:10 PM, "Zoltan Kiss" wrote: >=20 > >The current way is not the most efficient: if m->refcnt is 1, the seco= nd > >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 remo= ve > >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); > >=20 > >- if (likely (rte_mbuf_refcnt_read(m) =3D=3D 1) || > >- likely (rte_mbuf_refcnt_update(m, -1) =3D=3D 0)) { > >- > >- rte_mbuf_refcnt_set(m, 0); > >+ if (likely (rte_mbuf_refcnt_update(m, -1) =3D=3D 0)) { > >=20 > > /* if this is an indirect mbuf, then > > * - detach mbuf >=20 > I fell for this one too, but read Bruce=B9s 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 co= de itself! /Bruce > >--=20 > >1.9.1 > > >=20