Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmap: try THP via madvise #113

Open
wants to merge 2 commits into
base: v0.2.2_release
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mmap_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ impl MmapRegion {
return Err(Error::Mmap(io::Error::last_os_error()));
}

let _ret = unsafe { libc::madvise(addr, size, libc::MADV_HUGEPAGE) };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Apologies for the late reply :( I was just wondering, what's the difference between using this madvise call and providing MAP_HUGETLB as part of flags?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAP_HUGETLB uses hugetlbfs, MADV_HUGEPAGE uses transparent huge page for memfd or anonymous mapping.


Ok(Self {
addr: addr as *mut u8,
size,
Expand Down