From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 2941C1396; Sat, 10 Jun 2017 10:31:23 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id u101so11130529wrc.1; Sat, 10 Jun 2017 01:31:23 -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=69O0PcADOp4yOEdIDOo/1T5uC2PLxUQz7hIZ/tXfYJ8=; b=uXKtuS+FnQMiw3jo3uAOYXEHAugfMz7dtmhOW97owi+Z0Jcp4rmcb7DF8fcZx81CE3 kQyJo6brEPlq0Gu4Zo7jKvn7Tk9K4e437tKzKggW+hutYY4RGEftXD8q64iOt0Bc9Sui GTAhYY5JWLqOanVX1VgkTnVMt0kqnbr+tHqn6fZCPUc1rQozmhy2iB4Gx00W9BKWg/hc nR5//FW+gAzI2XRuZz1jv9XcEbxomrbye4VaKAJKL4iyJRm/kjhV9qpbQamRkgFCzboZ C++o+U7Ocrm+1M4sghNycbcM0RzI6t/2yiCGkuY+WtrUvwsG6Sc42mbjBgAY1mUZpRag UduQ== 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=69O0PcADOp4yOEdIDOo/1T5uC2PLxUQz7hIZ/tXfYJ8=; b=V+JOjjc6qBg98pr6gnR5qLZ0UtPgaLiig94CqO+DEObfBj851GMkcYPwujRp2m2jHx XJ4phc5pwHEp5fDKADy8bnP4ccDD4djGV99oZVfXT1ri22l/tlXjo5QNRWZ/9PmNdAEx fw2WSbVsMmmjmNr/zGtUmpcsfLtPk8nysFyk1nhI3UoA8moThDlXAifB7N+7YBiq/mUB C64tk0LA+3ZbcR7ipjFv5mApz1uqI/ct/uFVY51mIxUZ7uIwGeRfYlJVU3l5vtP+0bvk cVtDpxaT8SSUzohB+txJXbHqDqWZhXUi+FDvxrqqADmkyGs0meW6ZLSyueDp83ObPmEf teRg== X-Gm-Message-State: AODbwcDMMXGAkP24jMXESEPnwnqJdpOwo7IHqL5OXMZ/aR9wKCh/+/yj ucXIIKrRbUpoCvAvszazMfuVCR7Skg== X-Received: by 10.223.142.15 with SMTP id n15mr1792891wrb.131.1497083482678; Sat, 10 Jun 2017 01:31:22 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.25.65 with HTTP; Sat, 10 Jun 2017 01:31:22 -0700 (PDT) In-Reply-To: <20170609082937.21294-1-olivier.matz@6wind.com> References: <20170609102727.0eb7f39d@platinum> <20170609082937.21294-1-olivier.matz@6wind.com> From: Jan Blunck Date: Sat, 10 Jun 2017 10:31:22 +0200 X-Google-Sender-Auth: 90xVqwufGkw64OQrDZQROc9naxA Message-ID: To: Olivier Matz Cc: dev , matvejchikov@gmail.com, Adrien Mazarguil , sergio.gonzalez.monroy@intel.com, stable@dpdk.org Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH] eal: don't advertise a physical address when no hugepages X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jun 2017 08:31:23 -0000 On Fri, Jun 9, 2017 at 10:29 AM, 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 > --- > lib/librte_eal/common/eal_common_memzone.c | 5 ++++- > lib/librte_eal/linuxapp/eal/eal_memory.c | 7 +++++++ > lib/librte_mempool/rte_mempool.c | 2 +- > 3 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c > index 3026e36b8..c465c8fc2 100644 > --- a/lib/librte_eal/common/eal_common_memzone.c > +++ b/lib/librte_eal/common/eal_common_memzone.c > @@ -251,7 +251,10 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, > > mcfg->memzone_cnt++; > snprintf(mz->name, sizeof(mz->name), "%s", name); > - mz->phys_addr = rte_malloc_virt2phy(mz_addr); > + if (rte_eal_has_hugepages()) > + mz->phys_addr = rte_malloc_virt2phy(mz_addr); > + else > + mz->phys_addr = RTE_BAD_PHYS_ADDR; Since you set phys_addrs_available to false rte_malloc_virt2phy() anyway returns RTE_BAD_PHYS_ADDR so I believe the conditional isn't necessary here. Rest of the patch looks good to me. > mz->addr = mz_addr; > mz->len = (requested_len == 0 ? elem->size : requested_len); > mz->hugepage_sz = elem->ms->hugepage_sz; > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 9c9baf628..1c99852f6 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -108,6 +108,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, > 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 >