Skip to content

Commit

Permalink
sys::man adding MADV_POPULATE_READ and MAP_POPULATE_WRITE. (#2565)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devnexen authored Dec 18, 2024
1 parent 5674377 commit 4033e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog/2565.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add `sys::mman::MmapAdvise` `MADV_POPULATE_READ`, `MADV_POPULATE_WRITE` for Linux and Android targets

7 changes: 7 additions & 0 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 4033e06

Please sign in to comment.