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

Allow setting object metadata for VM space objects. Expose VO bit under a feature. #1248

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Dec 5, 2024

This PR changes a few things for vo bit:

  1. Add a function to set object metadata for an object in the VM space: MMTK::initialize_vm_space_object.
  2. Add a feature vo_bit_access to expose VO bit and a binding may use it at its own risk.
  3. Mark VO bit side metadata base address only avilable for 64 bits.

The second is needed for Julia. The Julia binding uses MMTk immortal allocation or VM space for a region of memory, and pop the regions with boot image objects with no clear way to identify each object. The easist workaround is to bulk set VO bit for the region. The problem from this is that MMTk cannot identify valid objects in those regions. However, Julia binding only uses VO bit for pinning objects. Objects in the immortal space or the VM space will not be moved so failing to pinning objects in those regions is benign. Currently the Julia binding duplicates a bunch of side metadata code to bulk set VO bit only using the VO bit side metadata base address. See mmtk/mmtk-julia#200

@qinsoon qinsoon marked this pull request as ready for review December 5, 2024 04:43
@qinsoon qinsoon requested a review from wks December 5, 2024 04:43
/// Objects in the VM space are allocated/managed by the binding. This functio provides a way for
/// the binding to set VO bit for an object in the space.
#[cfg(feature = "vm_space")]
pub fn set_vo_bit_for_vm_space_object<VM: VMBinding>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the mmtk::util::metadata::vo_bit module is pub(crate), and set_vo_bit_for_vm_space_object is not re-exported. So this method is still inaccessible to the VM binding although it is pub.

I suggest we make the vo_bit module pub, but make every pub items inside the vo_bit module pub(crate), and make set_vo_bit_for_vm_space_object pub. Then the VM binding can call this function by mmtk::util::metadata::vo_bit::set_vo_bit_for_vm_space_object.

I intended to do this refactoring anyway, and remove the is_mmtk_object feature, and move everything related to is_mmtk_object into vo_bit itself (see this issue).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the vo_bit module public. All the existing functions with pub are changed to pub(crate). VO_BIT_SIDE_METADATA_SPEC is exported from this module if the feature vo_bit_access is enabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I removed this function set_vo_bit_for_vm_space_object. I realized that a binding needs to set all the object metadata to properly initialize an object in the VM space. I added a function MMTK::initialize_vm_space_object() which calls SFT::initialize_object_metadata on vm_space.

src/util/metadata/side_metadata/mod.rs Outdated Show resolved Hide resolved
"{} is not in VM space",
object
);
set_vo_bit(object);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets a single VO bit at a time. Depending on the density of objects in the VM space, if this is a bottleneck, we can provide another function that allows the VM binding to provide a bitmap directly, and memcpy into our VO bit metadata (in a single pass, or chunk by chunk).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I feel this is out of scope for this PR.

@qinsoon qinsoon changed the title Allow setting VO bit for VM space objects. Expose VO bit under a feature. Allow setting object metadata for VM space objects. Expose VO bit under a feature. Dec 6, 2024
Copy link
Collaborator

@wks wks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qinsoon
Copy link
Member Author

qinsoon commented Dec 6, 2024

binding-refs
JULIA_BINDING_REPO=qinsoon/mmtk-julia
JULIA_BINDING_REF=use-mmtk-vo-bit-access

@qinsoon qinsoon added the PR-extended-testing Run extended tests for the pull request label Dec 6, 2024
@qinsoon qinsoon added this pull request to the merge queue Dec 9, 2024
Merged via the queue into mmtk:master with commit 2e548e5 Dec 9, 2024
32 of 34 checks passed
@qinsoon qinsoon deleted the vo-bit-access branch December 9, 2024 09:24
mmtkgc-bot added a commit to mmtk/mmtk-julia that referenced this pull request Dec 9, 2024
This PR updates to mmtk-core:
mmtk/mmtk-core#1248. This allows us to remove
the duplicate code for vo bit.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
@qinsoon qinsoon mentioned this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-extended-testing Run extended tests for the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants