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
Closed
Changes from all commits
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
7 changes: 6 additions & 1 deletion src/mm/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ impl ValidBitmap {
/// The number of u64's in the bitmap
fn bitmap_len(&self) -> usize {
let num_pages = self.region.len() / PAGE_SIZE;
num_pages.div_ceil(u64::BITS as usize)
let additional_u64 = if self.region.len() % PAGE_SIZE != 0 {
1
} else {
0
};
num_pages + additional_u64
Comment on lines +151 to +156
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
}

}

fn migrate(&mut self, new_bitmap: *mut u64) {
Expand Down