[crac] RFR: Correct System.nanotime() value after restore

Anton Kozlov akozlov at openjdk.org
Tue Mar 28 09:35:09 UTC 2023


On Tue, 28 Mar 2023 06:53:21 GMT, Radim Vansa <duke at openjdk.org> wrote:

>> src/hotspot/share/runtime/os.cpp line 2051:
>> 
>>> 2049:     diff_millis = 0;
>>> 2050:   }
>>> 2051:   javaTimeNanos_offset = checkpoint_nanos - javaTimeNanos() + diff_millis * 1000000L;
>> 
>> Will `uptime_since_restore` still report the correct time after the change?
>> 
>> https://github.com/openjdk/crac/blob/9ed961106a255145274de777e151577863b013ea/src/hotspot/os/linux/os_linux.cpp#L5697
>
> It should, since both times are read after restore.

restore_start_counter is indeed read on restore, in the process that execs into CREngine, so the value is not adjusted. The value then transfered to the restored VM via SHM [1] and then used for the difference between the javaTimeNanos() which is going to be adjusted. I'm worried the difference between not adjusted and adjusted value may lose sense.

Could you extend the NanoTimeTest to demonstrate the `uptime_since_restore` cannot become negative or "too" big?

[1] https://github.com/openjdk/crac/commit/9ed961106a255145274de777e151577863b013ea#diff-aeec57d804d56002f26a85359fc4ac8b48cfc249d57c656a30a63fc6bf3457adR6385

-------------

PR Review Comment: https://git.openjdk.org/crac/pull/53#discussion_r1150304555


More information about the crac-dev mailing list