RFR: 8364638: Refactor and make accumulated GC CPU time code generic [v5]

Stefan Johansson sjohanss at openjdk.org
Fri Aug 15 08:27:12 UTC 2025


On Fri, 15 Aug 2025 08:05:06 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>>> My concern is that we get a number on cpu-time without knowing the number is off by a large margin when failure occurs, so there should probably be some warning/msg somewhere.
>> 
>> Sure, that could be helpful. I don't think it should be a warning on the OS API though. Looking at the code a log message like that could be added to `CPUTimeThreadClosure::do_thread(...)`. To me it would be enough to have that on `log_info(cpu)` possibly even on debug-level. What do you think?
>
>>  I don't think it should be a warning on the OS API though.
> 
> Agree. At this level, returning `-1` already indicates the error -- callers should/can check the return-value and act on it.
> 
>> ... could be added to CPUTimeThreadClosure::do_thread(...)
> 
> There are dozens of callers though; `CPUTimeThreadClosure` is just one. For this particular patch, I think emitting some msg/warning somewhere inside `static void log_cpu_time` may be enough. WDYT?

I don't have super strong opinion here, but to be able to add some message in `log_cpu_time` we would need to add logic to the `CPUTimeThreadClosure` to know if something went wrong or am I missing what you are suggesting? 

And that message would not know what thread we failed to measure, but the closure have that information.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26621#discussion_r2278524140


More information about the serviceability-dev mailing list