-
Notifications
You must be signed in to change notification settings - Fork 75
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
Mask and zero bits in metadata bytes for bulk zeroing #707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One major problem is that if the metadata is discontiguous, the current way may overwrite unrelated metadata between chunks.
let zero = |data_start: Address, data_end: Address| { | ||
let meta_start = address_to_meta_address(self, data_start); | ||
let meta_start_shift = meta_byte_lshift(self, data_start); | ||
let meta_end = address_to_meta_address(self, data_end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is OK if the metadata is contiguous. But if it is discontiguous, then meta_start
and meta_end
may be in two unrelated chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed zero
to zero_contiguous
which uses the same implementation as what you reviewed, and added zero_discontiguous
which computes the total bits that need to be zeroed without computing the end address.
meta_start, | ||
address_to_meta_address(self, second_data_chunk) - meta_start, | ||
); | ||
zero(start, second_data_chunk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two problems:
- If
start
is already aligned toBYTES_IN_CHUNK
, thenstart.align_up(BYTES_IN_CHUNK)
will be equal tostart
, and it will end up callingzero(start, start)
. - If the metadata is discontiguous, passing
second_data_chunk
to thezero
function will result inmeta_end
being in a different metadata chunk, and unrelated metadata in between will be overwritten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I added a check, if the size to be zeroed is 0, then the method simply returns.
- See my reply for the above comments.
address_to_meta_address(self, next_data_chunk), | ||
metadata_bytes_per_chunk(self.log_bytes_in_region, self.log_num_of_bits), | ||
); | ||
zero(next_data_chunk, next_data_chunk + BYTES_IN_CHUNK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem here. next_data_chunk + BYTES_IN_CHUNK
will be mapped to the next metadata chunk.
discontiguous/chunked metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
let meta_total_bits = (data_bytes >> self.log_bytes_in_region) << self.log_num_of_bits; | ||
let meta_delta_bytes = meta_total_bits >> LOG_BITS_IN_BYTE; | ||
let meta_delta_bits: u8 = (meta_total_bits % BITS_IN_BYTE) as u8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. I think these lines of code are even clearer than those in address_to_contiguous_meta_address
and meta_byte_lshift
.
This PR fixes a bug in `bzero_metadata()` discussed in mmtk#643 (comment). When the data address range to be bulk zeroed cannot be mapped into whole bytes in the side metadata, the other bits in the bytes which should not be updated will get zeroed unexpectedly.
This PR fixes a bug in `bzero_metadata()` discussed in mmtk#643 (comment). When the data address range to be bulk zeroed cannot be mapped into whole bytes in the side metadata, the other bits in the bytes which should not be updated will get zeroed unexpectedly.
This PR fixes a bug in
bzero_metadata()
discussed in #643 (comment). When the data address range to be bulk zeroed cannot be mapped into whole bytes in the side metadata, the other bits in the bytes which should not be updated will get zeroed unexpectedly.