mem: mark pages as not accessed when reserving VA
PATCH 1/1 mem: mark pages as not accessed when reserving VA
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.
--- lib/librte_eal/common/eal_common_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_memory.c +1 -1
@@ -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;
Signature · 1 line
2.23.0
Quoted 27 lines · David Marchand
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_NONEwhen 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 <[email protected]>Signed-off-by David Marchand <[email protected]>--- lib/librte_eal/common/eal_common_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/common/eal_common_memory.c +0
-0
lib/librte_eal/common/eal_common_memory.c eal_get_virtual_area(void *requested_addr, size_t *size, · line 103
Quoted 8 lines
lib/librte_eal/common/eal_common_memory.c +1
-1@@ -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;
Thanks!
Maxime
Quoted 10 lines · David Marchand
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_NONEwhen only reserving VA. The memory allocator already switches to the right mode when making use of it.
Quoted 8 lines
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 <[email protected]>Signed-off-by David Marchand <[email protected]>---
Thanks!
Quoted 10 lines · David Marchand
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_NONEwhen only reserving VA. The memory allocator already switches to the right mode when making use of it.
Quoted 8 lines
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 <[email protected]>Signed-off-by David Marchand <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
David Marchand
Reviewed-by Maxime Coquelin Acked-by Aaron Conole Acked-by Anatoly Burakov on v1 1/1 AppliedQuoted 11 lines · David Marchand
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_NONEwhen only reserving VA. The memory allocator already switches to the right mode when making use of it.
Quoted 7 lines
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 <[email protected]>Signed-off-by David Marchand <[email protected]>
Applied.
Signature · 1 line
David Marchand