From 9debca9f193f31c2c791f1b752e588b512adae73 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 17 Dec 2024 23:14:06 +0000 Subject: [PATCH] sys::man adding `MADV_POPULATE_READ` and `MAP_POPULATE_WRITE`. More specialised than MmapFlags::MAP_POPULATE, another difference being it does not silently fail. - `MADV_POPULATE_READ` to pre-populate pages ahead of read accesses. - `MADV_POPULATE_WRITE` to pre-populate pages ahead of subsequent writes. --- src/sys/mman.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 833e8e182d..6bd724379a 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -328,6 +328,13 @@ libc_enum! { /// Undo `MADV_WIPEONFORK` when it applied. #[cfg(linux_android)] MADV_KEEPONFORK, + /// Pre-load the address range for reading to reduce page-fault latency. + #[cfg(linux_android)] + MADV_POPULATE_READ, + /// Pre-fault the address range for writing to reduce page-fault + /// latency on subsequent writes. + #[cfg(linux_android)] + MADV_POPULATE_WRITE, } }