From cc275a6878b2c8b924fde2f18db68c47bdd8c38e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 11 Dec 2024 07:03:26 +0000 Subject: [PATCH] sys::mman: adding few madvise flags. - `MADV_PAGEOUT` which reclaim the address range, swapping it out if the page is anonymous or written back to disk if it's backed up by a file. - `MADV_COLD` which deactivate the address range but as a hint. - `MADV_WIPEONFORK` after `fork()`, the address range is wiped out to avoid sharing sensible data between processes. - `MADV_KEEPONFORK` disables `MADV_WIPEONFORK` workflow. --- src/sys/mman.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 779e9a2172..833e8e182d 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -316,6 +316,18 @@ libc_enum! { #[cfg(apple_targets)] #[allow(missing_docs)] MADV_CAN_REUSE, + /// Reclaim the address range when applicable. + #[cfg(linux_android)] + MADV_PAGEOUT, + /// Deactivate the address range when applicable. + #[cfg(linux_android)] + MADV_COLD, + /// After fork, the adress range is zero filled. + #[cfg(linux_android)] + MADV_WIPEONFORK, + /// Undo `MADV_WIPEONFORK` when it applied. + #[cfg(linux_android)] + MADV_KEEPONFORK, } }