Getting per-thread CPU time on *BSD

Thomas Schatzl thomas.schatzl at oracle.com
Wed Jun 25 11:48:58 UTC 2025


Hi Harald,

On 23.06.25 09:46, Thomas Schatzl wrote:
> Hi Harald,
> 
>    thanks for your effort!
> 
> On 21.06.25 14:03, Harald Eilertsen wrote:
>> Hi,
>>
>> A quick update on my part.
>>
>> I have figured out how to get both user time and user+sys time on
>> FreeBSD.
>>
>> https://urldefense.com/v3/__https://git.anduin.net/haraldei/bsd- 
>> thread-time-example__;!!ACWV5N9M2RV99hQ! 
>> KBbaClb29ZBzy6EdTYhJCvZr14QJva2hOK77xk4iHj9UsZiM0q2WpJzM2- 
>> Yy0rIrpBA6ueo4LvMJJ90zr-K7IDN-PeWZ-p-s$
>>
>> This is quite similar to the OpenBSD code by Kurt Miller that was
>> already in the BSD port tree. I have a local patch based on that
> 
> I did not know somebody maintained the BSD port outside of mainline. 
> That may make the issue more complicated.
   actually it looks like there is at least a JDK 21 port which has the 
necessary infrastructure implemented.

I did not notice because it is maintained out of tree (link shows the 
changes for os::thread_cpu_time() here: 
https://github.com/battleblow/jdk21u/blob/bsd-port/src/hotspot/os/bsd/os_bsd.cpp).

Not sure how to proceed here for adding the suggested changes to mainline.

However it seems that these are the "official" changes, and probably we 
in the gc team will actually assume that the functionality is there and 
we may not provide workarounds in the future when depending on this, 
even if it's not in mainline.

Just out of curiosity, do you happen to know why the changes for *BSD 
are not upstreamed?

Thanks,
   Thomas



More information about the bsd-port-dev mailing list