From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e28smtp04.in.ibm.com (e28smtp04.in.ibm.com [125.16.236.4]) by dpdk.org (Postfix) with ESMTP id 39A0A2B95 for ; Thu, 17 Mar 2016 06:06:09 +0100 (CET) Received: from localhost by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Mar 2016 10:36:07 +0530 Received: from d28relay03.in.ibm.com (9.184.220.60) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 Mar 2016 10:36:04 +0530 X-IBM-Helo: d28relay03.in.ibm.com X-IBM-MailFrom: gowrishankar.m@linux.vnet.ibm.com X-IBM-RcptTo: dev@dpdk.org Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u2H5630t42467418 for ; Thu, 17 Mar 2016 10:36:04 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u2H561qK027746 for ; Thu, 17 Mar 2016 10:36:02 +0530 Received: from [9.79.202.124] ([9.79.202.124]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u2H55vTW027400; Thu, 17 Mar 2016 10:35:58 +0530 Message-ID: <56EA3B33.4040000@linux.vnet.ibm.com> Date: Thu, 17 Mar 2016 10:35:55 +0530 From: gowrishankar User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: dev@dpdk.org CC: david.marchand@6wind.com, thomas.monjalon@6wind.com References: <1457360003-30055-1-git-send-email-gowrishankar.m@linux.vnet.ibm.com> In-Reply-To: <1457360003-30055-1-git-send-email-gowrishankar.m@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 16031705-0013-0000-0000-00000AF20B33 Subject: Re: [dpdk-dev] [PATCH] eal/ppc: fix secondary process to map hugepages in correct order 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, 17 Mar 2016 05:06:09 -0000 Could this patch be reviewed please. Thanks, Gowrishankar On Monday 07 March 2016 07:43 PM, Gowrishankar wrote: > From: Gowri Shankar > > For a secondary process address space to map hugepages from every segment of > primary process, hugepage_file entries has to be mapped reversely from the > list that primary process updated for every segment. This is for a reason that, > in ppc64, hugepages are sorted for decrementing addresses. > > Signed-off-by: Gowrishankar > --- > lib/librte_eal/linuxapp/eal/eal_memory.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 5b9132c..6aea5d0 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -1400,7 +1400,7 @@ rte_eal_hugepage_attach(void) > { > const struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; > const struct hugepage_file *hp = NULL; > - unsigned num_hp = 0; > + unsigned num_hp = 0, mapped_hp = 0; > unsigned i, s = 0; /* s used to track the segment number */ > off_t size; > int fd, fd_zero = -1, fd_hugepage = -1; > @@ -1486,14 +1486,12 @@ rte_eal_hugepage_attach(void) > goto error; > } > > - num_hp = size / sizeof(struct hugepage_file); > - RTE_LOG(DEBUG, EAL, "Analysing %u files\n", num_hp); > - > s = 0; > while (s < RTE_MAX_MEMSEG && mcfg->memseg[s].len > 0){ > void *addr, *base_addr; > uintptr_t offset = 0; > size_t mapping_size; > + unsigned int index; > #ifdef RTE_LIBRTE_IVSHMEM > /* > * if segment has ioremap address set, it's an IVSHMEM segment and > @@ -1504,6 +1502,8 @@ rte_eal_hugepage_attach(void) > continue; > } > #endif > + num_hp = mcfg->memseg[s].len / mcfg->memseg[s].hugepage_sz; > + RTE_LOG(DEBUG, EAL, "Analysing %u files in segment %u\n", num_hp, s); > /* > * free previously mapped memory so we can map the > * hugepages into the space > @@ -1514,18 +1514,23 @@ rte_eal_hugepage_attach(void) > /* find the hugepages for this segment and map them > * we don't need to worry about order, as the server sorted the > * entries before it did the second mmap of them */ > +#ifdef RTE_ARCH_PPC_64 > + for (i = num_hp-1; i < num_hp && offset < mcfg->memseg[s].len; i--){ > +#else > for (i = 0; i < num_hp && offset < mcfg->memseg[s].len; i++){ > - if (hp[i].memseg_id == (int)s){ > - fd = open(hp[i].filepath, O_RDWR); > +#endif > + index = i + mapped_hp; > + if (hp[index].memseg_id == (int)s){ > + fd = open(hp[index].filepath, O_RDWR); > if (fd < 0) { > RTE_LOG(ERR, EAL, "Could not open %s\n", > - hp[i].filepath); > + hp[index].filepath); > goto error; > } > #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS > - mapping_size = hp[i].size * hp[i].repeated; > + mapping_size = hp[index].size * hp[index].repeated; > #else > - mapping_size = hp[i].size; > + mapping_size = hp[index].size; > #endif > addr = mmap(RTE_PTR_ADD(base_addr, offset), > mapping_size, PROT_READ | PROT_WRITE, > @@ -1534,7 +1539,7 @@ rte_eal_hugepage_attach(void) > if (addr == MAP_FAILED || > addr != RTE_PTR_ADD(base_addr, offset)) { > RTE_LOG(ERR, EAL, "Could not mmap %s\n", > - hp[i].filepath); > + hp[index].filepath); > goto error; > } > offset+=mapping_size; > @@ -1543,6 +1548,7 @@ rte_eal_hugepage_attach(void) > RTE_LOG(DEBUG, EAL, "Mapped segment %u of size 0x%llx\n", s, > (unsigned long long)mcfg->memseg[s].len); > s++; > + mapped_hp += num_hp; > } > /* unmap the hugepage config file, since we are done using it */ > munmap((void *)(uintptr_t)hp, size);