From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id C5CC02A6C for ; Wed, 15 Nov 2017 09:50:44 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 00:50:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,398,1505804400"; d="scan'208";a="2850592" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by fmsmga001.fm.intel.com with ESMTP; 15 Nov 2017 00:50:40 -0800 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by IRSMSX108.ger.corp.intel.com (163.33.3.3) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 15 Nov 2017 08:50:39 +0000 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.67]) by irsmsx112.ger.corp.intel.com ([169.254.1.12]) with mapi id 14.03.0319.002; Wed, 15 Nov 2017 08:50:38 +0000 From: "Ananyev, Konstantin" To: Hanoh Haim , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage Thread-Index: AQHTXezU/xzKsh0jCk+WgKXM7laQjaMVIGOQ Date: Wed, 15 Nov 2017 08:50:38 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772585FABD34F@irsmsx105.ger.corp.intel.com> References: <20171115083548.18572-1-hhaim@cisco.com> In-Reply-To: <20171115083548.18572-1-hhaim@cisco.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTVkZGI5NjgtZGY5YS00MTY2LWE2ZTItMTlhM2I2MzBmMGJkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImtGNWFJZHQwT2VzNTZDUkFUVlQwd2c4UG92XC9TSDFkcXRxZkdMNHNZQzJBPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2017 08:50:45 -0000 Hi Hanon, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Hanoh Haim > Sent: Wednesday, November 15, 2017 8:36 AM > To: dev@dpdk.org > Cc: Hanoh Haim > Subject: [dpdk-dev] [PATCH] mbuf: cleanup rte_pktmbuf_lastseg(), fix atom= ic usage >=20 > Signed-off-by: Hanoh Haim > --- > lib/librte_mbuf/rte_mbuf.h | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 7e326bb..ab110f8 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1159,6 +1159,15 @@ static inline void rte_pktmbuf_reset(struct rte_mb= uf *m) > __rte_mbuf_sanity_check(m, 1); > } >=20 > + > +static __rte_always_inline void rte_pktmbuf_reset_before_free(struct rte= _mbuf *m) > +{ > + if (m->next !=3D NULL) { > + m->next =3D NULL; > + m->nb_segs =3D 1; > + } > +} > + > /** > * Allocate a new mbuf from a mempool. > * > @@ -1323,8 +1332,7 @@ static inline void rte_pktmbuf_detach(struct rte_mb= uf *m) > m->ol_flags =3D 0; >=20 > if (rte_mbuf_refcnt_update(md, -1) =3D=3D 0) { > - md->next =3D NULL; > - md->nb_segs =3D 1; > + rte_pktmbuf_reset_before_free(md); > rte_mbuf_refcnt_set(md, 1); > rte_mbuf_raw_free(md); > } > @@ -1354,25 +1362,16 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > - > + rte_pktmbuf_reset_before_free(m); > return m; >=20 > - } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) =3D=3D = 0) { > - > + } else if (rte_mbuf_refcnt_update(m, -1) =3D=3D 0) { That would cause extra read; cmp (and possible slowdown) for atomic refcnt. If that really need to be fixed - probably we need to introduce a new funct= ion that would do update without trying to read refctn first - rte_mbuf_refcnt_= update_blind() or so. Konstantin >=20 > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > + rte_pktmbuf_reset_before_free(m); > rte_mbuf_refcnt_set(m, 1); > - > return m; > } > return NULL; > -- > 2.9.3