Is there a way to pre-populate the operating system's page table for a large Rust allocation?

Viewed 201

If you try allocate a large chunk of memory using any of Rust's memory allocation mechanisms (including nightly alloc_api) you cannot pre-populate the page table i.e. you cant recreate the MAP_POPULATE option of mmap. Instead, I just use libc::mmap when I need to allocate large areas of memory.

Is there another way to pre-populate the page table in Rust other than looping through a Vec<usize> or Vec<SomeTypeOfPageSize> and triggering page faults?

As pointed out by @FlorianWeimer, there are platform specific ways of doing this. I will scan the Rust RFCs to see if the new allocator API includes any pre-populate options.

1 Answers
Related