From 4033e0627612f4955444113a34e66b7dccd7dd35 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 18 Dec 2024 01:16:20 +0000 Subject: [PATCH] sys::man adding `MADV_POPULATE_READ` and `MAP_POPULATE_WRITE`. (#2565) 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. --- changelog/2565.added.md | 2 ++ src/sys/mman.rs | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 changelog/2565.added.md diff --git a/changelog/2565.added.md b/changelog/2565.added.md new file mode 100644 index 0000000000..5d476de128 --- /dev/null +++ b/changelog/2565.added.md @@ -0,0 +1,2 @@ +Add `sys::mman::MmapAdvise` `MADV_POPULATE_READ`, `MADV_POPULATE_WRITE` for Linux and Android targets + 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, } }