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

Filter the result for find_prev_non_zero_value_fast to make sure it is in the search range #1192

Merged
merged 1 commit into from
Sep 2, 2024
Merged
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: 7 additions & 0 deletions src/util/metadata/side_metadata/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ impl SideMetadataSpec {
let end_addr = data_addr;

// Then figure out the start and end metadata address and bits.
// The start bit may not be accurate, as we map any address in the region to the same bit.
// We will filter the result at the end to make sure the found address is in the search range.
let start_meta_addr = address_to_contiguous_meta_address(self, start_addr);
let start_meta_shift = meta_byte_lshift(self, start_addr);
let end_meta_addr = address_to_contiguous_meta_address(self, end_addr);
Expand Down Expand Up @@ -1120,7 +1122,12 @@ impl SideMetadataSpec {
&mut visitor,
);

// We have to filter the result. We search between [start_addr, end_addr). But we actually
// search with metadata bits. It is possible the metadata bit for start_addr is the same bit
// as an address that is before start_addr. E.g. 0x2010f026360 and 0x2010f026361 are mapped
// to the same bit, 0x2010f026361 is the start address and 0x2010f026360 is outside the search range.
res.map(|addr| addr.align_down(1 << self.log_bytes_in_region))
.filter(|addr| *addr >= start_addr && *addr < end_addr)
}

/// Search for data addresses that have non zero values in the side metadata. This method is
Expand Down
Loading