[crac] RFR: 8368929: [CRaC] Move CPUFeatures check to C/R engine
Jan Kratochvil
jkratochvil at openjdk.org
Wed Oct 1 08:53:08 UTC 2025
On Tue, 30 Sep 2025 13:17:54 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
> Right now the logic checking if CPU features used before checkpoint match current CPU features is in VM code. VM stores and retrieves CPU features through C/R API's user_data extension. This is convenient when we have a single image that can be either accepted or rejected, but does not offer the flexibility for C/R engine to select the best image for current execution environment.
>
> The goal of this issue is to move to a declarative API that will express the requirements using more abstract means, labels (for CPU architecture) and bitmaps (for CPU features).
src/hotspot/share/include/crlib/crlib.h line 85:
> 83: #define RESTORE_ERROR_INVALID -4 // image is not suitable (e.g. corruption or wrong architecture)
> 84: #define RESTORE_ERROR_MEMORY -5 // memory allocation failure during restore
> 85: #define RESTORE_ERROR_PROCINFO -6 // the process cannot fetch information about itself
Cannot it be an enum?
src/hotspot/share/runtime/crac.cpp line 527:
> 525: // Since the check itself is delegated to the C/R Engine we will simply
> 526: // skip the check here (or prevent storing the features in the image).
> 527: #ifdef __x86_64__
One should not use `#ifdef` as it may lead to compilation errors on other arches.
src/hotspot/share/runtime/crac.cpp line 589:
> 587: if (ret == RESTORE_ERROR_INVALID) {
> 588: log_error(crac)("CRaC engine failed to restore from %s: the image is either corrupted or does not match current CPU", CRaCRestoreFrom);
> 589: #ifdef __x86_64__
Likewise one should not use `#ifdef` as it may lead to compilation errors on other arches.
src/java.base/share/native/libcrexec/image_constraints.cpp line 39:
> 37:
> 38: static FILE *open_tags(const char *image_location, const char *mode) {
> 39: char fname[PATH_MAX];
whitespace
src/java.base/share/native/libcrexec/image_constraints.cpp line 61:
> 59: fprintf(f, LABEL_PREFIX "%s=%s\n", tag.name, static_cast<const char *>(tag.data));
> 60: } else {
> 61: fprintf(f, BITMAP_PREFIX "%s=", tag.name);
indentation 2 vs. 4
src/java.base/share/native/libcrexec/image_constraints.cpp line 77:
> 75:
> 76: static inline unsigned char from_hex(char c, bool *err) {
> 77: if (c >= '0' && c <= '9') {
again changed indentation, more occurences in this file
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393876679
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393871031
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393871594
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393878601
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393881789
PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2393884186
More information about the crac-dev
mailing list