Skip to content

Commit

Permalink
mem: mark pages as not accessed when reserving VA
Browse files Browse the repository at this point in the history
[ upstream commit 8a4baf0 ]

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.

Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
david-marchand authored and kevintraynor committed May 27, 2020
1 parent 19a69e5 commit 444b643
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librte_eal/common/eal_common_memory.c
Expand Up @@ -112,7 +112,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;
Expand Down

0 comments on commit 444b643

Please sign in to comment.