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

Fix un-cleared VO bits for contiguous monotone PR #1071

Merged
merged 1 commit into from
Jan 16, 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
Fix un-cleared VO bits for contiguous monotone PR
Fixed a bug that when using a generational plan, if mutators allocated
less than one chunk of memory into the nursery between GCs, some VO bits
will not be cleared.

This PR also ensures the field `MonotonePageResourceSync::current_chunk`
grows monotonically during GC when the space is contiguous.
  • Loading branch information
wks committed Jan 15, 2024
commit 51d0615f113dd528970041855a1bfda3c23b620b
17 changes: 2 additions & 15 deletions src/policy/copyspace.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ use crate::policy::space::{CommonSpace, Space};
use crate::scheduler::GCWorker;
use crate::util::alloc::allocator::AllocatorContext;
use crate::util::copy::*;
#[cfg(feature = "vo_bit")]
use crate::util::heap::layout::vm_layout::BYTES_IN_CHUNK;
use crate::util::heap::{MonotonePageResource, PageResource};
use crate::util::metadata::{extract_side_metadata, MetadataSpec};
use crate::util::object_forwarding;
@@ -189,19 +187,8 @@ impl<VM: VMBinding> CopySpace<VM> {

#[cfg(feature = "vo_bit")]
unsafe fn reset_vo_bit(&self) {
let current_chunk = self.pr.get_current_chunk();
if self.common.contiguous {
// If we have allocated something into this space, we need to clear its VO bit.
if current_chunk != self.common.start {
crate::util::metadata::vo_bit::bzero_vo_bit(
self.common.start,
current_chunk + BYTES_IN_CHUNK - self.common.start,
);
}
} else {
for (start, size) in self.pr.iterate_allocated_regions() {
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
}
for (start, size) in self.pr.iterate_allocated_regions() {
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
}
}

7 changes: 7 additions & 0 deletions src/util/heap/monotonepageresource.rs
Original file line number Diff line number Diff line change
@@ -140,6 +140,12 @@ impl<VM: VMBinding> PageResource<VM> for MonotonePageResource<VM> {

/* In a contiguous space we can bump along into the next chunk, so preserve the currentChunk invariant */
if self.common().contiguous && chunk_align_down(sync.cursor) != sync.current_chunk {
debug_assert!(
chunk_align_down(sync.cursor) > sync.current_chunk,
"Not monotonic. chunk_align_down(sync.cursor): {}, sync.current_chunk: {}",
chunk_align_down(sync.cursor),
sync.current_chunk,
);
sync.current_chunk = chunk_align_down(sync.cursor);
}
self.commit_pages(reserved_pages, required_pages, tls);
@@ -310,6 +316,7 @@ impl<VM: VMBinding> MonotonePageResource<VM> {
MonotonePageResourceConditional::Contiguous { start: _start, .. } => _start,
_ => unreachable!(),
};
guard.current_chunk = guard.cursor;
} else if !guard.cursor.is_zero() {
let bytes = guard.cursor - guard.current_chunk;
self.release_pages_extent(guard.current_chunk, bytes);