DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: echaudro@redhat.com, aconole@redhat.com,
	maxime.coquelin@redhat.com, stable@dpdk.org,
	Andrea Arcangeli <aarcange@redhat.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH] mem: mark pages as not accessed when reserving VA
Date: Mon,  9 Mar 2020 15:54:42 +0100	[thread overview]
Message-ID: <20200309145442.28926-1-david.marchand@redhat.com> (raw)

When the memory allocator reserves virtual addresses, it still does not
know what they will be used for.
Besides, huge areas are reserved for memory hotplug in multiprocess
setups. But most of the pages are unused in the whole life of the
processes.

Change protection mode to PROT_NONE when only reserving VA.
The memory allocator already switches to the right mode when making use
of it.

It also has the nice effect of getting those pages skipped by the kernel
when calling mlockall() or when a coredump gets generated.

Cc: stable@dpdk.org

Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 4a9cc1f19..cc7d54e0c 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -97,7 +97,7 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 			return NULL;
 		}
 
-		mapped_addr = mmap(requested_addr, (size_t)map_sz, PROT_READ,
+		mapped_addr = mmap(requested_addr, (size_t)map_sz, PROT_NONE,
 				mmap_flags, -1, 0);
 		if (mapped_addr == MAP_FAILED && allow_shrink)
 			*size -= page_sz;
-- 
2.23.0


             reply	other threads:[~2020-03-09 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 14:54 David Marchand [this message]
2020-03-09 15:27 ` Maxime Coquelin
2020-03-10 13:57 ` Aaron Conole
2020-03-10 16:26 ` Burakov, Anatoly
2020-03-13  9:59 ` [dpdk-dev] [dpdk-stable] " David Marchand

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=20200309145442.28926-1-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=aconole@redhat.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=echaudro@redhat.com \
    --cc=maxime.coquelin@redhat.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).