DPDK patches and discussions
 help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: Olivier Matz <olivier.matz@6wind.com>,
	sergio.gonzalez.monroy@intel.com, david.marchand@6wind.com,
	thomas.monjalon@6wind.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] mem: skip memory locking on failure
Date: Tue, 14 Jun 2016 16:21:38 +0300	[thread overview]
Message-ID: <e39265df-14a6-9511-6bc9-1e097909a292@redhat.com> (raw)
In-Reply-To: <1465813577-13780-1-git-send-email-olivier.matz@6wind.com>

On 06/13/2016 01:26 PM, Olivier Matz wrote:
> Since recently [1], it is not possible to run the dpdk with user
> (non-root) privileges and the --no-huge option. This is because the eal
> layer tries to lock the memory. Using locked memory is mandatory for
> physical devices because they reference physical addresses.
>
> But a user may want to start the dpdk without locked memory, because he
> does not have the permission to do so, and/or does not have this need.
>
> Moreover, the option --no-huge is still not functional today since the
> physical memory address is not properly filled, so the initial patch is
> not really useful.
>
> This commit fixes this issue by retrying the mmap() wihout the
> MAP_LOCKED flag if the first mmap() failed.
>
> [1] http://www.dpdk.org/ml/archives/dev/2016-May/039404.html
>
> Fixes: 593a084afc2b ("mem: lock pages when not using hugepages")
> Reported-by: Panu Matilainen <pmatilai@redhat.com>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal_memory.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 79d1d2d..08692d1 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -1075,6 +1075,15 @@ rte_eal_hugepage_init(void)
>  	if (internal_config.no_hugetlbfs) {
>  		addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE,
>  			MAP_LOCKED | MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> +		/* retry without MAP_LOCKED */
> +		if (addr == MAP_FAILED && errno == EAGAIN) {
> +			addr = mmap(NULL, internal_config.memory,
> +				PROT_READ | PROT_WRITE,
> +				MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> +			if (addr != MAP_FAILED)
> +				RTE_LOG(NOTICE, EAL,
> +					"Cannot lock memory: don't use physical devices\n");
> +		}
>  		if (addr == MAP_FAILED) {
>  			RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
>  					strerror(errno));
>

I'm not really that familiar with dpdk memory usage, but gut feeling 
says such a thing needs to be explicit - either you explicitly ask for 
memory that doesn't need to be locked, or this simply fails with no 
retries. Or something like that. But "maybe I did, maybe I didn't" 
doesn't seem like very good API semantics to me :)

Are there actual plans to make --no-huge work with real devices? If not 
then documenting --no-huge to imply unlocked memory is one option I guess.

	- Panu -

	- Panu -

  reply	other threads:[~2016-06-14 13:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-13 10:26 Olivier Matz
2016-06-14 13:21 ` Panu Matilainen [this message]
2016-06-14 14:12   ` Olivier MATZ
2016-06-21 11:58     ` Panu Matilainen
2016-06-27 15:58 ` [dpdk-dev] [PATCH v2] mem: revert page locking when not using hugepages Olivier Matz
2016-06-30 17:17   ` 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=e39265df-14a6-9511-6bc9-1e097909a292@redhat.com \
    --to=pmatilai@redhat.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=sergio.gonzalez.monroy@intel.com \
    --cc=thomas.monjalon@6wind.com \
    /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).