RFR: 8372584: [Linux]: Replace reading proc to get thread user CPU time with clock_gettime [v3]

Jonas Norlinder jnorlinder at openjdk.org
Mon Dec 1 11:53:57 UTC 2025


On Mon, 1 Dec 2025 04:08:23 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Jonas Norlinder has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Remove unused imports
>
> src/hotspot/os/linux/os_linux.cpp line 4979:
> 
>> 4977:     // to detach itself from the VM - which should result in ESRCH.
>> 4978:     assert_status(rc == ESRCH, rc, "pthread_getcpuclockid failed");
>> 4979:     *success = false;
> 
> The normal way I've seen this pattern used is to set it to true rather than assuming it was true to begin with.

Using a positive outcome like success to encode the outcome make it possible to return like so `return success ? os::Linux::thread_cpu_time(clockid) : -1;`. I prefer having the `-1` at the end as I find this reads easier. If we encode a failure we would need to write `return !failure ? os::Linux::thread_cpu_time(clockid) : -1;`. Hence, I would prefer keeping this as is as double-negatives may be harder to parse.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28556#discussion_r2576747078


More information about the hotspot-runtime-dev mailing list