From 02d53a8d572c06f3dae26126917553b58cb4cb3a Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Wed, 14 Jun 2023 16:53:13 -0700 Subject: [PATCH] Set MAP_POPULATE on guest mmap This directs the Linux kernel to set up page tables eagerly instead of the default lazy behaviour, and shaves about 2 ms off the FreeBSD kernel boot time. Signed-off-by: Colin Percival --- src/vm-memory/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm-memory/src/lib.rs b/src/vm-memory/src/lib.rs index 85ad72421fc4..edb0462e881e 100644 --- a/src/vm-memory/src/lib.rs +++ b/src/vm-memory/src/lib.rs @@ -120,7 +120,7 @@ pub fn create_guest_memory( for region in regions { let flags = match region.0 { - None => libc::MAP_NORESERVE | libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + None => libc::MAP_NORESERVE | libc::MAP_POPULATE | libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, Some(_) => libc::MAP_NORESERVE | libc::MAP_PRIVATE, };