From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 985F81B295 for ; Wed, 14 Feb 2018 13:12:02 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 04:12:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="204046710" Received: from bricha3-mobl3.ger.corp.intel.com ([10.252.19.81]) by fmsmga005.fm.intel.com with SMTP; 14 Feb 2018 04:11:59 -0800 Received: by (sSMTP sendmail emulation); Wed, 14 Feb 2018 12:11:58 +0000 Date: Wed, 14 Feb 2018 12:11:57 +0000 From: Bruce Richardson To: "Ananyev, Konstantin" Cc: Yongseok Koh , Olivier Matz , "dev@dpdk.org" Message-ID: <20180214121157.GA3116@bricha3-MOBL3.ger.corp.intel.com> References: <97910E4F-11F5-4BDB-A460-2656B88EA87D@mellanox.com> <2601191342CEEE43887BDE71AB97725890572EA2@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB97725890572EC6@irsmsx105.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB97725890572EC6@irsmsx105.ger.corp.intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.1 (2017-09-22) 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:12:03 -0000 On Wed, Feb 14, 2018 at 12:03:55PM +0000, Ananyev, Konstantin wrote: > > > > -----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_seg() > > > > Hi Yongseok, > > > > > > 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 thought the > > > > following patch could be helpful. I haven't had them try it yet but just 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 != NULL) { > > > > + if (m->nb_segs > 1) { > > > > m->next = NULL; > > > > m->nb_segs = 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 != NULL) { > > > > + if (m->nb_segs > 1) { > > > > m->next = NULL; > > > > m->nb_segs = 1; > > > > } > > > > > > Well, m->pool in the 2nd cacheline has to be accessed anyway in order to put it back to the mempool. > > > It looks like the cache miss is unavoidable. > > > > As a thought: in theory PMD can store pool pointer together with each mbuf it has to free, > > then it could be something like: > > > > if (rte_pktmbuf_prefree_seg(m[x] != NULL) > > rte_mempool_put(pool[x], m[x]); > > > > 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==1, but m->next != 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 It's still worth considering as an option. We could check nb_segs for the first segment of a packet and thereafter iterate using the next pointer. It means that your idea of storing the pool pointer for each mbuf becomes useful for single-segment packets. /Bruce