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

Add MapFlags::map_hugetlb_with_size_log2 #2125

Merged
merged 3 commits into from Nov 14, 2023

Conversation

newpavlov
Copy link
Contributor

Closes #2124

src/sys/mman.rs Outdated
/// `Some(MapFlags::MAP_HUGETLB | MAP_HUGE_1GB)`.
#[cfg(target_os = "linux")]
#[cfg_attr(docsrs, doc(cfg(all())))]
pub fn map_hugetlb_with_shift(huge_page_size_log2: u8) -> Option<Self> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't make it const because I couldn't find a way to convert i32 into InternalBitFlags.

@newpavlov newpavlov changed the title Add MapFlags::map_hugetlb_with_shift Add MapFlags::map_hugetlb_with_size_log2 Oct 2, 2023
@newpavlov newpavlov force-pushed the hugetlb_shift branch 2 times, most recently from 879460f to 1ab8175 Compare October 2, 2023 09:42
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Don't forget a changelog entry.

/// let f = MapFlags::map_hugetlb_with_size_log2(30).unwrap();
/// assert_eq!(f, MapFlags::MAP_HUGETLB | MapFlags::MAP_HUGE_1GB);
/// ```
#[cfg(target_os = "linux")]
Copy link
Member

Choose a reason for hiding this comment

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

This should probably include android and fuchsia, too. At least, libc defines MAP_HUGETLB for those platforms. But it doesn't define MAP_HUGE_SHIFT. Is that an oversight in libc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that an oversight in libc?

Maybe. Either way, we would need first introduce the constant to libc and only then add expand list of targets, so I think it's better to do it in a later PR.

Copy link
Member

Choose a reason for hiding this comment

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

I filed a PR adding these symbols for Android or Linux: rust-lang/libc#3444

@SteveLauC
Copy link
Member

We can merge this PR as-is, but @newpavlov could you please leave a TODO here: support Andorid and Fuchsia when libc 0.2.151 gets released

@SteveLauC SteveLauC added this pull request to the merge queue Nov 14, 2023
Merged via the queue into nix-rust:master with commit 3b16f0c Nov 14, 2023
35 checks passed
@newpavlov newpavlov deleted the hugetlb_shift branch November 14, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose MAP_HUGE_SHIFT
3 participants