From mboxrd@z Thu Jan 1 00:00:00 1970 From: gowrishankar muthukrishnan Subject: Re: [PATCH v4 44/70] net/mlx5: use virt2memseg instead of iteration Date: Mon, 9 Apr 2018 15:56:31 +0530 Message-ID: <02565d9e-333e-e406-25f8-863aa897d864@linux.vnet.ibm.com> References: <0541a675ec4a7906e50ddfa8881446c98158666a.1523218215.git.anatoly.burakov@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Adrien Mazarguil , Nelio Laranjeiro , Yongseok Koh , keith.wiles@intel.com, jianfeng.tan@intel.com, andras.kovacs@ericsson.com, laszlo.vadkeri@ericsson.com, benjamin.walker@intel.com, bruce.richardson@intel.com, thomas@monjalon.net, konstantin.ananyev@intel.com, kuralamudhan.ramakrishnan@intel.com, louise.m.daly@intel.com, pepperjo@japf.ch, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, olivier.matz@6wind.com, shreyansh.jain@nxp.com To: Anatoly Burakov , dev@dpdk.org Return-path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by dpdk.org (Postfix) with ESMTP id 5C6452C5E for ; Mon, 9 Apr 2018 12:26:46 +0200 (CEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w39AOKb3014670 for ; Mon, 9 Apr 2018 06:26:45 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h81s6khnp-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 09 Apr 2018 06:26:44 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Apr 2018 11:26:42 +0100 In-Reply-To: <0541a675ec4a7906e50ddfa8881446c98158666a.1523218215.git.anatoly.burakov@intel.com> Content-Language: en-GB List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Monday 09 April 2018 01:48 AM, Anatoly Burakov wrote: > Reduce dependency on internal details of EAL memory subsystem, and > simplify code. > > Signed-off-by: Anatoly Burakov > --- > drivers/net/mlx5/mlx5_mr.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c > index 2bf1f9c..d8c04dc 100644 > --- a/drivers/net/mlx5/mlx5_mr.c > +++ b/drivers/net/mlx5/mlx5_mr.c > @@ -234,7 +234,7 @@ struct mlx5_mr * > mlx5_mr_new(struct rte_eth_dev *dev, struct rte_mempool *mp) > { > struct priv *priv = dev->data->dev_private; > - const struct rte_memseg *ms = rte_eal_get_physmem_layout(); > + const struct rte_memseg *ms; > uintptr_t start; > uintptr_t end; > unsigned int i; Unused variable 'i' to be removed. Thanks, Gowrishankar > @@ -261,17 +261,15 @@ mlx5_mr_new(struct rte_eth_dev *dev, struct rte_mempool *mp) > /* Save original addresses for exact MR lookup. */ > mr->start = start; > mr->end = end; > + > /* Round start and end to page boundary if found in memory segments. */ > - for (i = 0; (i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL); ++i) { > - uintptr_t addr = (uintptr_t)ms[i].addr; > - size_t len = ms[i].len; > - unsigned int align = ms[i].hugepage_sz; > + ms = rte_mem_virt2memseg((void *)start); > + if (ms != NULL) > + start = RTE_ALIGN_FLOOR(start, ms->hugepage_sz); > + ms = rte_mem_virt2memseg((void *)end); > + if (ms != NULL) > + end = RTE_ALIGN_CEIL(end, ms->hugepage_sz); > > - if ((start > addr) && (start < addr + len)) > - start = RTE_ALIGN_FLOOR(start, align); > - if ((end > addr) && (end < addr + len)) > - end = RTE_ALIGN_CEIL(end, align); > - } > DRV_LOG(DEBUG, > "port %u mempool %p using start=%p end=%p size=%zu for memory" > " region",