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 6FCDD1B2CD for ; Wed, 14 Feb 2018 13:03:58 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 04:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="30676708" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by fmsmga001.fm.intel.com with ESMTP; 14 Feb 2018 04:03:56 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.221]) by IRSMSX108.ger.corp.intel.com ([169.254.11.9]) with mapi id 14.03.0319.002; Wed, 14 Feb 2018 12:03:55 +0000 From: "Ananyev, Konstantin" To: "Ananyev, Konstantin" , Yongseok Koh , Olivier Matz CC: "dev@dpdk.org" Thread-Topic: Accessing 2nd cacheline in rte_pktmbuf_prefree_seg() Thread-Index: AQHTpRxoSpjpp7VOiUGxw51sLWTbeaOjOjMAgACJaVCAAAlJYA== Date: Wed, 14 Feb 2018 12:03:55 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725890572EC6@irsmsx105.ger.corp.intel.com> References: <97910E4F-11F5-4BDB-A460-2656B88EA87D@mellanox.com> <2601191342CEEE43887BDE71AB97725890572EA2@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB97725890572EA2@irsmsx105.ger.corp.intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDg2NGU3Y2YtNjY0OC00ZDgzLTlhYjMtZmRmYmNmODczMjY4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImFyOTRpQzVwalppMlNcL0dWS3BLRjlENHQwdU1ad0s3cHk4Z2ZNWFh6NzBrPSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] Accessing 2nd cacheline in rte_pktmbuf_prefree_seg() 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, 14 Feb 2018 12:03:59 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ananyev, Konstantin > Sent: Wednesday, February 14, 2018 11:48 AM > To: Yongseok Koh ; Olivier Matz > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] Accessing 2nd cacheline in rte_pktmbuf_prefree_se= g() >=20 > Hi Yongseok, >=20 > > > On Feb 13, 2018, at 2:45 PM, Yongseok Koh wrote: > > > > > > Hi Olivier > > > > > > I'm wondering why rte_pktmbuf_prefree_seg() checks m->next instead of > > > m->nb_segs? As 'next' is in the 2nd cacheline, checking nb_segs seems= beneficial > > > to the cases where almost mbufs have single segment. > > > > > > A customer reported high rate of cache misses in the code and I thoug= ht the > > > following patch could be helpful. I haven't had them try it yet but j= ust wanted > > > to hear from you. > > > > > > I'd appreciate if you can review this idea. > > > > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > > index 62740254d..96edbcb9e 100644 > > > --- a/lib/librte_mbuf/rte_mbuf.h > > > +++ b/lib/librte_mbuf/rte_mbuf.h > > > @@ -1398,7 +1398,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > > > if (RTE_MBUF_INDIRECT(m)) > > > rte_pktmbuf_detach(m); > > > > > > - if (m->next !=3D NULL) { > > > + if (m->nb_segs > 1) { > > > m->next =3D NULL; > > > m->nb_segs =3D 1; > > > } > > > @@ -1410,7 +1410,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > > > if (RTE_MBUF_INDIRECT(m)) > > > rte_pktmbuf_detach(m); > > > > > > - if (m->next !=3D NULL) { > > > + if (m->nb_segs > 1) { > > > m->next =3D NULL; > > > m->nb_segs =3D 1; > > > } > > > > Well, m->pool in the 2nd cacheline has to be accessed anyway in order t= o put it back to the mempool. > > It looks like the cache miss is unavoidable. >=20 > As a thought: in theory PMD can store pool pointer together with each mbu= f it has to free, > then it could be something like: >=20 > if (rte_pktmbuf_prefree_seg(m[x] !=3D NULL) > rte_mempool_put(pool[x], m[x]); >=20 > Then what you suggested above might help. After another thought - we have to check m->next not m->nb_segs. There could be a situations where nb_segs=3D=3D1, but m->next !=3D NULL (2-nd segment of the 3 segment packet for example). So probably we have to keep it as it is. Sorry for the noise Konstantin