From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 1BCD21094; Mon, 3 Jul 2017 12:17:07 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id j85so19551026wmj.0; Mon, 03 Jul 2017 03:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=6DpSB//yJOBLM8gVTy+NDTW4Z1EBvcwDPE6tQfJ29y4=; b=lnZw1qUuSKC6sauxs9cwplPfF4CC3T2aYmkNWVmu4LZzRGA0Y6xUFxV4Pm/rGpHQTU +mzzqXClte3nne+jtGZd5v08+6ulSJTG2ZrcrNmlA5FsaSZpaScH3TUxYGVVNi7mqX93 FHbaUYmUJka46u119wtJ/2rNbXSqkBwznegMSGlnEpUxMEePmFfqLpQteVcTaAlI23O9 SMsIGuHwKXKikCryUTcyvNqCqqy6iDli9xe5BgGtCio8fwvuIutDeRlwIJ5PtS5X0DFe oYMGW5bVfXnL0yh4BqtP9dO3QZiOYQrFyaB0tXZl+RsTOPnO/3MuMAwah+QGHzGATrPH VhLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=6DpSB//yJOBLM8gVTy+NDTW4Z1EBvcwDPE6tQfJ29y4=; b=AeuEelgXKGeknVe6+2Sn+prWAHNCduf2dt6TjNt4eah9FPSg+3j0zGHvTg2GTvqc5n jgR1a5DtUytv6usni2YeZ1yRBSl5kTUAaTXbMJJEeMn4JrlHpG9GJXLPCvUSmrkjejMO +LAMvdOoR8OTRNCSpDQiAPaOWNmw0To9M5a7nnDNGLQ/pP+16wEFnMaov236yI0aqhp/ 5pTrQx88/n1K2YWVGSyY3ch18qC8HQEV/4Kv0I2NPNzBVlUPMEY0+ZQObAJm0fL9Eg99 dkshpQ2Y+vfCYYO31R0w3f7Gwg9b0XJ8ScoAxc3sZgG8RzrlPFpkbVsMNRD52jNXMZVM d/xQ== X-Gm-Message-State: AIVw110oDOt1Njz02sYqNa6vA/gs72S7sGq9BHnhFMedQPvGJAirFGxd Ftez3UOOSvXhWOrgnw3/gc5/us/vUw== X-Received: by 10.28.198.1 with SMTP id w1mr4830785wmf.78.1499077026739; Mon, 03 Jul 2017 03:17:06 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.5.132 with HTTP; Mon, 3 Jul 2017 03:17:06 -0700 (PDT) In-Reply-To: <20170703100407.21790-1-olivier.matz@6wind.com> References: <20170609082937.21294-1-olivier.matz@6wind.com> <20170703100407.21790-1-olivier.matz@6wind.com> From: Jan Blunck Date: Mon, 3 Jul 2017 12:17:06 +0200 X-Google-Sender-Auth: AM7J9y4Y6vWekcxH-xZwgVWAQBA Message-ID: To: Olivier Matz Cc: dev , Ilya Matveychikov , Adrien Mazarguil , sergio.gonzalez.monroy@intel.com, santosh.shukla@caviumnetworks.com, stable@dpdk.org Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2] eal: don't advertise a physical address when no hugepages 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: Mon, 03 Jul 2017 10:17:07 -0000 On Mon, Jul 3, 2017 at 12:04 PM, Olivier Matz wrote: > When populating a mempool with a virtual memory area, the mempool > library expects to be able to get the physical address of each page. > > When started with --no-huge, the physical addresses may not be available > because the pages are not locked in memory. It sometimes returns > RTE_BAD_PHYS_ADDR, which makes the mempool_populate() function to fail. > > This was working before the commit cdc242f260e7 ("eal/linux: support > running as unprivileged user"), because rte_mem_virt2phy() was returning > 0 instead of RTE_BAD_PHYS_ADDR, which was seen as a valid physical > address. > > Since --no-huge is a debug function that breaks the support of physical > drivers, always set physical addresses to RTE_BAD_PHYS_ADDR in memzones > or in rte_mem_virt2phy(), and ensure that mempool won't complain in that > case. > > Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user") > > CC: stable@dpdk.org > Signed-off-by: Olivier Matz Reviewed-by: Jan Blunck > --- > > v1 -> v2: > - initialize memory segments (rte_memseg) with RTE_BAD_PHYS_ADDR > if started with --no-huge > - return RTE_BAD_PHYS_ADDR when rte_malloc_virt2phy() if the > memory segment has no physical address > - drop change in eal_common_memzone.c: the physical address is > now set to RTE_BAD_PHYS_ADDR as per return value of > rte_malloc_virt2phy() > > > lib/librte_eal/common/include/rte_malloc.h | 2 +- > lib/librte_eal/common/rte_malloc.c | 4 +++- > lib/librte_eal/linuxapp/eal/eal_memory.c | 9 ++++++++- > lib/librte_mempool/rte_mempool.c | 2 +- > 4 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h > index 61aac322b..3d37f79b8 100644 > --- a/lib/librte_eal/common/include/rte_malloc.h > +++ b/lib/librte_eal/common/include/rte_malloc.h > @@ -329,7 +329,7 @@ rte_malloc_set_limit(const char *type, size_t max); > * @param addr > * Address obtained from a previous rte_malloc call > * @return > - * NULL on error > + * RTE_BAD_PHYS_ADDR on error > * otherwise return physical address of the buffer > */ > phys_addr_t > diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c > index f4a883529..5c0627bf4 100644 > --- a/lib/librte_eal/common/rte_malloc.c > +++ b/lib/librte_eal/common/rte_malloc.c > @@ -253,6 +253,8 @@ rte_malloc_virt2phy(const void *addr) > { > const struct malloc_elem *elem = malloc_elem_from_data(addr); > if (elem == NULL) > - return 0; > + return RTE_BAD_PHYS_ADDR; > + if (elem->ms->phys_addr == RTE_BAD_PHYS_ADDR) > + return RTE_BAD_PHYS_ADDR; > return elem->ms->phys_addr + ((uintptr_t)addr - (uintptr_t)elem->ms->addr); > } > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 647d89c58..040f24a43 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -112,6 +112,13 @@ test_phys_addrs_available(void) > if (rte_xen_dom0_supported()) > return; > > + if (!rte_eal_has_hugepages()) { > + RTE_LOG(ERR, EAL, > + "Started without hugepages support, physical addresses not available\n"); > + phys_addrs_available = false; > + return; > + } > + > physaddr = rte_mem_virt2phy(&tmp); > if (physaddr == RTE_BAD_PHYS_ADDR) { > RTE_LOG(ERR, EAL, > @@ -1054,7 +1061,7 @@ rte_eal_hugepage_init(void) > strerror(errno)); > return -1; > } > - mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr; > + mcfg->memseg[0].phys_addr = RTE_BAD_PHYS_ADDR; > mcfg->memseg[0].addr = addr; > mcfg->memseg[0].hugepage_sz = RTE_PGSIZE_4K; > mcfg->memseg[0].len = internal_config.memory; > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index f65310f60..6fc3c9c7c 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -476,7 +476,7 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, > /* required for xen_dom0 to get the machine address */ > paddr = rte_mem_phy2mch(-1, paddr); > > - if (paddr == RTE_BAD_PHYS_ADDR) { > + if (paddr == RTE_BAD_PHYS_ADDR && rte_eal_has_hugepages()) { > ret = -EINVAL; > goto fail; > } > -- > 2.11.0 >