jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v7]

Martin Doerr mdoerr at openjdk.org
Mon Oct 6 11:04:53 UTC 2025


On Thu, 25 Sep 2025 14:35:51 GMT, Suchismith Roy <sroy at openjdk.org> wrote:

>> JBS Issue : [JDK-8030957](https://bugs.openjdk.org/browse/JDK-8030957)
>> 
>> These two methods should be implemented in src/aix/native/sun/management/AixOperatingSystem.c (which has to be created).
>> 
>> getProcessCpuLoad() can be probably implemented in the same way like on Solaris be reading /proc/self/psinfo
>> 
>> For getSystemCpuLoad() we'll probalby have to use 'perfstat_cpu_total()' from libperf (see http://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.prftools/doc/prftools/prftools07.htm#wq407)
>> 
>> Once this issue has been resolved the below two excludes must be removed from jdk/test/ProblemList.txt:
>> 
>> com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java aix-all
>> com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java aix-all
>
> Suchismith Roy has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update UnixOperatingSystem.c
>   
>   change sequence

This looks good. Thanks for implementing it! A few minor nits.

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 34:

> 32: #include <stdlib.h>
> 33: #include <libperfstat.h>
> 34: #include <pthread.h>

This is outside of hotspot, but I'd still sort includes (HotSpot style guide says "Keep the include lines sorted.").

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 36:

> 34: #include <pthread.h>
> 35: #include "com_sun_management_internal_OperatingSystemImpl.h"
> 36: #define HTIC2SEC(x) (((double)(x) * XINTFRAC) / 1000000000.0)

I'd prefer using `HTIC2NANOSEC(timebase_diff) / 1000000000.0` and removing this macro. It's only used at one place.

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 91:

> 89:             load = 0.0;
> 90:         }
> 91:         else {

Coding style: We typically don't start a new line for `else`.

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 128:

> 126:         counters.stats = curr_stats;
> 127:         counters.timebase = curr_timebase;
> 128:         if(delta_time == 0) {

Whitespace after `if`.

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 130:

> 128:         if(delta_time == 0) {
> 129:             cpu_load = 0.0;
> 130:         }

Same here.

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

PR Review: https://git.openjdk.org/jdk/pull/25332#pullrequestreview-3303835839
PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2405682597
PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2405699968
PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2405708424
PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2405710898
PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2405710177


More information about the jmx-dev mailing list