patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@infradead.org>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev <dev@dpdk.org>, Ilya Matveychikov <matvejchikov@gmail.com>,
	 Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	sergio.gonzalez.monroy@intel.com, stable@dpdk.org
Subject: Re: [dpdk-stable] [PATCH] eal: don't advertise a physical address when no hugepages
Date: Fri, 23 Jun 2017 19:08:51 +0200	[thread overview]
Message-ID: <CALe+Z03HuTQoYTT_W0=B4MBHWy9GWwOATmrtPqog0AxsvsRJvw@mail.gmail.com> (raw)
In-Reply-To: <20170623101157.43dcafe3@platinum>

On Fri, Jun 23, 2017 at 10:11 AM, Olivier Matz <olivier.matz@6wind.com> wrote:
> Hi Jan,
>
> On Sat, 10 Jun 2017 10:31:22 +0200, Jan Blunck <jblunck@infradead.org> wrote:
>> On Fri, Jun 9, 2017 at 10:29 AM, Olivier Matz <olivier.matz@6wind.com> 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 <olivier.matz@6wind.com>
>> > ---
>> >  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.
>
> The variable phys_addrs_available only impacts rte_mem_virt2phy().
> Here, for memzones allocation, rte_malloc_virt2phy() is used, and
> it gets its physical address by retrieving it from the memseg structure.
>
> With the full patch, "dump_memzone" displays something like:
>   Zone 0: name:<rte_eth_dev_data>, phys:0xffffffffffffffff, len:0x30100, [...]
>   ...
>
> If I strip the memzone part, it displays:
>   Zone 0: name:<rte_eth_dev_data>, phys:0x7fe382c62640, len:0x30100, [...]
>   ...
>
> So I think we should either keep the patch as is, or change the memseg
> and malloc part like this (it's maybe better):
>
>   --- a/lib/librte_eal/common/rte_malloc.c
>   +++ b/lib/librte_eal/common/rte_malloc.c
>   @@ -254,5 +254,7 @@ rte_malloc_virt2phy(const void *addr)
>           const struct malloc_elem *elem = malloc_elem_from_data(addr);
>           if (elem == NULL)
>                   return 0;
>   +       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 1c99852..2a401ca 100644
>   --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
>   +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
>   @@ -973,7 +973,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;
>
>
> Let me know what you are ok with this and I'll send a v2.
>

This approach looks better to me.

Thanks,
Jan

  reply	other threads:[~2017-06-23 17:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170609102727.0eb7f39d@platinum>
2017-06-09  8:29 ` Olivier Matz
2017-06-10  8:31   ` Jan Blunck
2017-06-23  8:11     ` Olivier Matz
2017-06-23 17:08       ` Jan Blunck [this message]
2017-06-26  7:11         ` [dpdk-stable] [dpdk-dev] " santosh
2017-06-12 13:58   ` [dpdk-stable] " Adrien Mazarguil
2017-07-03 10:04   ` [dpdk-stable] [PATCH v2] " Olivier Matz
2017-07-03 10:17     ` Jan Blunck
2017-07-04 15:53       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALe+Z03HuTQoYTT_W0=B4MBHWy9GWwOATmrtPqog0AxsvsRJvw@mail.gmail.com' \
    --to=jblunck@infradead.org \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=matvejchikov@gmail.com \
    --cc=olivier.matz@6wind.com \
    --cc=sergio.gonzalez.monroy@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).