On Wed, 6 Aug 2025 15:08:18 GMT, Suchismith Roy <s...@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 you should not forget to remove the two >> excludes 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 ProblemList.txt Changes requested by stuefe (Reviewer). src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 43: > 41: static perfstat_cpu_total_t cpu_total_old; > 42: static time_t last_sample_time = 0; > 43: static double last_cpu_load = -1.0; Not threadsafe. What happens if you call this concurrently from multiple threads? Visibility of these three values can be in any order of updates. You'd get skewed values. Check out how Linux does it. They use mutexes to synchronize access to this function. src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 54: > 52: if (initialized && (now - last_sample_time < 5)) { > 53: return last_cpu_load; // Return cached value if less than 5s > 54: } Are you sure this is needed? How slow is perfstat_cpu_total? src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c line 102: > 100: prev_timebase = curr_stats.last_timebase; > 101: initialized = 1; > 102: return -1.0; Here, and above in the other function: this seems wrong and would result in the first measurement to be off (or very large if displayed as unsigned). See how Linux does it in perfInit(). ------------- PR Review: https://git.openjdk.org/jdk/pull/25332#pullrequestreview-3095405436 PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2259126398 PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2259127887 PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2259157137