vmm: Enable THP when using anonymous memory
If the memory is not backed by a file then it is possible to enable Transparent Huge Pages on the memory and take advantage of the benefits of huge pages without requiring the specific allocation of an appropriate number of huge pages. TEST=Boot and see that in /proc/`pidof cloud-hypervisor`/smaps that the region is now THPeligible (and that also pages are being used.) Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
0f44db5da4
commit
b68add2d0d
1 changed files with 13 additions and 0 deletions
|
|
@ -1336,6 +1336,19 @@ impl MemoryManager {
|
|||
)
|
||||
.map_err(Error::GuestMemory)?;
|
||||
|
||||
if region.file_offset().is_none() {
|
||||
info!(
|
||||
"Anonymous mapping at 0x{:x} (size = 0x{:x})",
|
||||
region.as_ptr() as u64,
|
||||
size
|
||||
);
|
||||
let ret = unsafe { libc::madvise(region.as_ptr() as _, size, libc::MADV_HUGEPAGE) };
|
||||
if ret != 0 {
|
||||
let e = io::Error::last_os_error();
|
||||
warn!("Failed to mark pages as THP eligible: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply NUMA policy if needed.
|
||||
if let Some(node) = host_numa_node {
|
||||
let addr = region.deref().as_ptr();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue