Skip to content

8385359: [CRaC] aarch64: c7g.medium <-> c8g.medium FAIL: vector length - #331

Draft
jankratochvil wants to merge 79 commits into
openjdk:cracfrom
jankratochvil:8385359
Draft

jankratochvil wants to merge 79 commits into
openjdk:cracfrom
jankratochvil:8385359

Conversation

@jankratochvil

@jankratochvil jankratochvil commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

It is a draft src/hotspot/share/runtime/crac_engine.cpp needs to be reworked. I believe crlib_image_constraints::get_failed_bitmap should become get_bitmap as this code needs to query image's CPUFeatures to find out its vector length to configure the CPU before restore. Otherwise one could also create some new user data. @rvansa?



Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8385359: [CRaC] aarch64: c7g.medium <-> c8g.medium FAIL: vector length (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/crac.git pull/331/head:pull/331
$ git checkout pull/331

Update a local copy of the PR:
$ git checkout pull/331
$ git pull https://git.openjdk.org/crac.git pull/331/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 331

View PR using the GUI difftool:
$ git pr show -t 331

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/crac/pull/331.diff

Using Webrev

Link to Webrev Comment

@jankratochvil
jankratochvil marked this pull request as draft July 23, 2026 02:36
@bridgekeeper

bridgekeeper Bot commented Jul 23, 2026

Copy link
Copy Markdown

👋 Welcome back jkratochvil! A progress list of the required criteria for merging this PR into crac will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jul 23, 2026

Copy link
Copy Markdown

@jankratochvil This change is no longer ready for integration - check the PR body for details.

@rvansa

rvansa commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

The image constraints was meant as structured data that is validated by the engine. The check is performed in the engine as to move JVM out of the loop when there are more images and score-based criteria. On the other hand, user_data is meant to be data opaque to the engine - so this fits better into the picture.

The only downside of adding get_bitmap and get_label methods to the API is that in practice the values will have to be stored in the configuration until it is destroyed - this is not a strong con, the data is minimal. Duplicating entry storage in user data ain't ideal either, anyway. Let's not change get_failed_bitmap, though - the API should evolve append-only.

@TimPushkin what's your opinion on the suggested API change?

Comment thread src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Outdated
Comment thread src/hotspot/os_cpu/linux_aarch64/vm_version_linux_aarch64.cpp Outdated
@TimPushkin

Copy link
Copy Markdown
Collaborator

Adding get_bitmap and get_label to the constraints API LGTM: if we have setters it feels natural to have getters.

Comment thread src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Outdated
@TimPushkin

Copy link
Copy Markdown
Collaborator

Nitpick: consider using pre_restore instead of restore_pre — the former convention seems more common in HotSpot

@jankratochvil
jankratochvil marked this pull request as ready for review September 13, 2026 22:15
@openjdk openjdk Bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 13, 2026
@jankratochvil
jankratochvil marked this pull request as draft September 14, 2026 03:59
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 14, 2026
@jankratochvil
jankratochvil marked this pull request as ready for review September 14, 2026 04:20
@openjdk openjdk Bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 14, 2026
Comment thread src/hotspot/share/runtime/crac.cpp Outdated
Comment on lines +73 to +78
// Register callbacks before restore. Callbacks are called only during restore.
// If the callback returns false the restore is aborted.
// name is not copied, its content must remain valid.
// user_data is an arbitrary pointer value which is passed along.
bool (*register_label_hook)(crlib_conf_t *, const char *name, bool (*hook)(const char *value, void *user_data), void *user_data);
bool (*register_bitmap_hook)(crlib_conf_t *, const char *name, bool (*hook)(const unsigned char *value, size_t value_size, void *user_data), void *user_data);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems to me that if require_label/bitmap copies the name it would be pretty inconsistent to not copy it here. On the other hand it is not possible to copy an arbitrary user pointer. One way to work this around would be to not specify the name at all, and let engine pass it as a hook argument (for any tag stored).

However, there is a bigger problem with this API design: the whole point of image constraints API extension is to validate the image & current environment compatibility externally. The image lookup can happen out of the process, e.g. on a remote server storing multiple images - with this hook API we would need to retrieve the tag for each image, send it over to this process, invoke the hook (looking for a first match, or doing that will all images, in case we are validating multiple tags?) and then forward the choice back to the server, and then get the right image... The API does not say if the hook is mutating, or idempotent. This is totally invalidating the point of the API.

I think that we need to break VM_Version::process_image_cpu_features into two parts: one that does the compatibility check (and that would be 'descriptor match'), and the other part tries to invoke prctl and fails the restore when the result is unexpected.

@jankratochvil
jankratochvil marked this pull request as draft September 14, 2026 09:01
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 14, 2026

@rvansa rvansa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mostly LGTM.

In the future it would be nice to move the static stubs into a base class, so we don't need to repeat then for every platform, but let's not slow down the integration here.

Comment thread src/java.base/share/native/libcrcommon/image_constraints.cpp Outdated
Comment thread src/java.base/share/native/libcrcommon/image_constraints.hpp Outdated
@jankratochvil

Copy link
Copy Markdown
Collaborator Author

It seems to me that if require_label/bitmap copies the name it would be pretty inconsistent to not copy it here. On the other hand it is not possible to copy an arbitrary user pointer. One way to work this around would be to not specify the name at all, and let engine pass it as a hook argument (for any tag stored).

I do not get all the parts but regarding the copying we were discussing it here with @TimPushkin and I find it would complicate the current code and the caller currently does not need it at all. If it is ever needed in the future one can start copying it in a fully backward compatible way.

Which reminds me also that I introduced the new API call get_bitmap to preserve existing get_failed_bitmap but IMO it would be perfectly backward compatible to just rename existing get_failed_bitmap to get_bitmap.

TBH I also do not understand why to currently be so strict with backward compatibility as it is all shipped in one bundle (even downstream). One can start considering backward compatibility if there is some 3rd party API implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants