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

mm: replace recently unstable bitmap_len() #169

Closed
wants to merge 1 commit into from

Conversation

Zildj1an
Copy link
Contributor

The usage of the unstable library feature 'int_roundings' would trigger a compilation error (See Rust issue #88581). Replace it with a standard integer division.

This is the error:

error[E0658]: use of unstable library feature 'int_roundings'
   --> src/mm/validate.rs:151:19
    |
151 |         num_pages.div_ceil(u64::BITS as usize)
    |                   ^^^^^^^^
    |
    = note: see issue #88581 <https://github.com/rust-lang/rust/issues/88581> for more information

Fixes: 2b0162d (mm/validate: migrate all pages in bitmap)

@00xc
Copy link
Member

00xc commented Nov 29, 2023

div_ceil should be stable since Rust 1.73. Have you updated your toolchain?

The usage of the unstable library feature 'int_roundings' would trigger
a compilation error (See Rust issue #88581) for versions of the Rust
toolchain that are recent but not the latest. Replace it with a standard
integer division.

Signed-off-by: Carlos Bilbao <carlos.bilbao@amd.com>
@Zildj1an Zildj1an changed the title mm: replace unstable bitmap_len() mm: replace recently unstable bitmap_len() Nov 29, 2023
@Zildj1an
Copy link
Contributor Author

div_ceil should be stable since Rust 1.73. Have you updated your toolchain?

You're absolutely correct! Doing rustup update solved it. I have removed the Fixes tag and updated the commit message; even though this works for latest toolchains I think we should still apply this change, given that we don't really need this (recently unstable) utility to perform the operation at hand.

Comment on lines +151 to +156
let additional_u64 = if self.region.len() % PAGE_SIZE != 0 {
1
} else {
0
};
num_pages + additional_u64
Copy link
Member

Choose a reason for hiding this comment

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

Not a strong opinion, but eventually we can avoid additional_u64 and do something like this:

Suggested change
let additional_u64 = if self.region.len() % PAGE_SIZE != 0 {
1
} else {
0
};
num_pages + additional_u64
if self.region.len() % PAGE_SIZE != 0 {
num_pages + 1
} else {
num_pages
}

@joergroedel
Copy link
Member

I think we can leave the code as-is, Rust 1.73 is from October so we can expect developers to update.

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.

4 participants