-
Notifications
You must be signed in to change notification settings - Fork 76
Global allocation bit #390
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
Conversation
Can you merge with master and resolve conflicts? |
The build still fails. You can probably try run |
This should fix the problem. I ran .github/scripts/ci-build.sh locally and it successfully built. |
The JikesRVM tests still failed. I don't think it is the known issue as mmtk/mmtk-jikesrvm#78. Probably worth looking into that. The error message about 'not in RVM space' basically means it is possibly a segfault in Rust code. @YiluoWei |
Seems that sometimes, the (probably the first) page_mark metadata is not mapped. On rat, it has an around 50% chance to pass.
|
I see. Then it is possible that this is the same issue as mmtk/mmtk-jikesrvm#78. |
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.
There are two things that are missing.
- The alloc bit is not implemented for the Immix policy, which was added recently. The alloc bit is not implemented for
LockFreeImmortalSpace
as well. - There is no test/assertion to check if the alloc bit is implemented correctly. This is why 1 would happen. As we are not using the alloc bit right now (except marksweep and 'malloc space'), testing it directly would not be easy. But it is possible to add assertions to check alloc bit (guarded by
extreme_assertions
).
I would suggest adding some assertions to check if alloc bit is correct. These are just some examples:
- before we set alloc bit for an object, the bit should be 0 before we set it (add the assertion to
set_alloc_bit()
). - before we unset alloc bit for an object, the bit should be 1 before we unset it (add the assertion to
unset_alloc_bit()
). - in
trace_object()
for each policy, ifglobal_alloc_bit
is enabled, the bit should be 1 before tracing.
Then I would suggest add alloc bit implementation for the immix space and the lockfree immortal space.
src/policy/copyspace.rs
Outdated
@@ -38,7 +40,11 @@ impl<VM: VMBinding> SFT for CopySpace<VM> { | |||
fn is_sane(&self) -> bool { | |||
!self.from_space() | |||
} | |||
fn initialize_object_metadata(&self, _object: ObjectReference, _alloc: bool) {} | |||
fn initialize_object_metadata(&self, _object: ObjectReference, _alloc: bool) { | |||
// This is only effective in slow path. We do not call post_alloc in fast path |
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 don't understand this line of comment. Did you mean for OpenJDK, we do not call post_alloc in fastpath? If so, I feel this is irrelevant to mmtk-core and this line should be removed.
@@ -136,8 +138,14 @@ impl<VM: VMBinding> MarkSweep<VM> { | |||
options: Arc<UnsafeOptionsWrapper>, | |||
) -> Self { | |||
let heap = HeapMeta::new(HEAP_START, HEAP_END); | |||
#[cfg(feature = "global_alloc_bit")] |
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.
Some comments are needed here because this looks counter-intuitive. Normally people will expect that, with global_alloc_bit
, we need the alloc bit spec. But we are not adding the alloc bit spec for global_alloc_bit
, as in that case, the spec is already added to the global specs in new_global_specs()
.
src/policy/mallocspace/global.rs
Outdated
@@ -172,7 +172,7 @@ impl<VM: VMBinding> MallocSpace<VM> { | |||
metadata: SideMetadataContext { | |||
global: global_side_metadata_specs, | |||
local: metadata::extract_side_metadata(&[ | |||
MetadataSpec::OnSide(ALLOC_SIDE_METADATA_SPEC), | |||
// MetadataSpec::OnSide(ALLOC_SIDE_METADATA_SPEC), |
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.
Remove this instead of commenting it out.
src/policy/mallocspace/metadata.rs
Outdated
log_num_of_bits: 0, | ||
log_min_obj_size: constants::LOG_MIN_OBJECT_SIZE as usize, | ||
}; | ||
// pub(crate) const ALLOC_SIDE_METADATA_SPEC: SideMetadataSpec = SideMetadataSpec { |
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.
Remove this instead of commenting it out.
@@ -153,11 +153,11 @@ pub fn is_alloced(object: ObjectReference) -> bool { | |||
} | |||
|
|||
pub fn is_alloced_object(address: Address) -> bool { |
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 feel most of these functions can be removed. You can directly call to alloc_bit::...
@@ -106,6 +113,7 @@ pub const GLOBAL_SIDE_METADATA_VM_BASE_OFFSET: SideMetadataOffset = | |||
// - Offset after Immix block mark byte | |||
// 6 - Immix chumk-map mark byte: | |||
// - Offset after Immix chumk-map mark byte | |||
// 1 - MarkSweep Active Page byte |
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.
This seems to be a merging problem.
log_num_of_bits: 0, | ||
log_min_obj_size: constants::LOG_MIN_OBJECT_SIZE as usize, | ||
}; | ||
|
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.
Need comments for the functions below. For unsafe functions, we also need comments to explain why they are unsafe, and how to correctly call them.
Is there any other change you would like to add to this PR? Otherwise, I think we can merge it. @YiluoWei |
I think we can merge it. |
Create new module util::alloc_bit.
Create new feature global_alloc_bit.
Create a new global side metadata for the alloc bit. 1 bit per min object size.
Add the alloc bit spec to plans.
Set alloc bit in initialize_object_metadata() for each policy.
Unset/zero bits for each policy.
Remove the alloc bit spec in MallocSpace, and change all the related functions to use the functions from the new alloc bit module.
issue:
Need to set the alloc bit in the allocation fastpath in OpenJDK, since we do not call post_alloc in the fastpath.
issue:
https://github.com/mmtk/mmtk-core/blob/master/src/policy/space.rs#L238
This function works for now, becuase we only use it to see whether an address is mapped, but it might be problematic.