From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 7DF04A69 for ; Thu, 26 Mar 2015 22:00:36 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 26 Mar 2015 14:00:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,474,1422950400"; d="scan'208";a="671178236" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by orsmga001.jf.intel.com with ESMTP; 26 Mar 2015 14:00:35 -0700 Received: from orsmsx155.amr.corp.intel.com (10.22.240.21) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 26 Mar 2015 14:00:35 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by ORSMSX155.amr.corp.intel.com (10.22.240.21) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 26 Mar 2015 14:00:35 -0700 Received: from fmsmsx113.amr.corp.intel.com ([169.254.13.22]) by FMSMSX157.amr.corp.intel.com ([169.254.14.241]) with mapi id 14.03.0195.001; Thu, 26 Mar 2015 14:00:34 -0700 From: "Wiles, Keith" To: Zoltan Kiss , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] mbuf: optimize refcnt handling during free Thread-Index: AQHQZ/sfD/WxMqFZR0G3Kvl0PV13k50vYVqA Date: Thu, 26 Mar 2015 21:00:33 +0000 Message-ID: References: <1427393457-7080-1-git-send-email-zoltan.kiss@linaro.org> In-Reply-To: <1427393457-7080-1-git-send-email-zoltan.kiss@linaro.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.107.172] Content-Type: text/plain; charset="iso-8859-1" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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:00:36 -0000 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); >=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 I fell for this one too, but read Bruce=B9s email http://dpdk.org/ml/archives/dev/2015-March/014481.html >--=20 >1.9.1 >