From sroy at openjdk.org Wed Aug 6 13:43:17 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Wed, 6 Aug 2025 13:43:17 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v3] In-Reply-To: References: Message-ID: > 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 with a new target base due to a merge or a rebase. The pull request now contains eight commits: - Merge branch 'master' into cpuprocessload - Merge branch 'master' into cpuprocessload - Update UnixOperatingSystem.c - Merge branch 'openjdk:master' into cpuprocessload - cleanup - system cpu load - restore problem list - cpu process load ------------- Changes: https://git.openjdk.org/jdk/pull/25332/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=02 Stats: 79 lines in 2 files changed: 73 ins; 2 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/25332.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/25332/head:pull/25332 PR: https://git.openjdk.org/jdk/pull/25332 From mbaesken at openjdk.org Wed Aug 6 13:51:04 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Wed, 6 Aug 2025 13:51:04 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v3] In-Reply-To: References: Message-ID: On Wed, 6 Aug 2025 13:43:17 GMT, Suchismith Roy 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 with a new target base due to a merge or a rebase. The pull request now contains eight commits: > > - Merge branch 'master' into cpuprocessload > - Merge branch 'master' into cpuprocessload > - Update UnixOperatingSystem.c > - Merge branch 'openjdk:master' into cpuprocessload > - cleanup > - system cpu load > - restore problem list > - cpu process load test/jdk/ProblemList.txt line 558: > 556: > 557: > 558: com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java 8364314 generic-all Wondering - why is that added ? Is it intended ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2257230418 From sroy at openjdk.org Wed Aug 6 14:13:05 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Wed, 6 Aug 2025 14:13:05 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v3] In-Reply-To: References: Message-ID: <3Vwjg-ioaRzQHhcP2VoZTnDl9SSLk2BLlsoJ22Gia44=.5222663d-8705-47cc-a060-2b57f92f119a@github.com> On Wed, 6 Aug 2025 13:48:15 GMT, Matthias Baesken wrote: >> Suchismith Roy has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits: >> >> - Merge branch 'master' into cpuprocessload >> - Merge branch 'master' into cpuprocessload >> - Update UnixOperatingSystem.c >> - Merge branch 'openjdk:master' into cpuprocessload >> - cleanup >> - system cpu load >> - restore problem list >> - cpu process load > > test/jdk/ProblemList.txt line 558: > >> 556: >> 557: >> 558: com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java 8364314 generic-all > > Wondering - why is that added ? Is it intended ? @MBaesken it was part of master branch. shall I remove it ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2257317031 From mbaesken at openjdk.org Wed Aug 6 14:17:04 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Wed, 6 Aug 2025 14:17:04 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v3] In-Reply-To: <3Vwjg-ioaRzQHhcP2VoZTnDl9SSLk2BLlsoJ22Gia44=.5222663d-8705-47cc-a060-2b57f92f119a@github.com> References: <3Vwjg-ioaRzQHhcP2VoZTnDl9SSLk2BLlsoJ22Gia44=.5222663d-8705-47cc-a060-2b57f92f119a@github.com> Message-ID: On Wed, 6 Aug 2025 14:10:44 GMT, Suchismith Roy wrote: >> test/jdk/ProblemList.txt line 558: >> >>> 556: >>> 557: >>> 558: com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java 8364314 generic-all >> >> Wondering - why is that added ? Is it intended ? > > @MBaesken it was part of master branch. shall I remove it ? Did not expect this in your PR . Bit unsure why it is there. It is not here https://github.com/openjdk/jdk/blob/master/test/jdk/ProblemList.txt so why is it needed in your PR ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2257330020 From sroy at openjdk.org Wed Aug 6 15:08:18 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Wed, 6 Aug 2025 15:08:18 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v3] In-Reply-To: References: <3Vwjg-ioaRzQHhcP2VoZTnDl9SSLk2BLlsoJ22Gia44=.5222663d-8705-47cc-a060-2b57f92f119a@github.com> Message-ID: On Wed, 6 Aug 2025 14:14:53 GMT, Matthias Baesken wrote: >> @MBaesken it was part of master branch. shall I remove it ? > > Did not expect this in your PR . > Bit unsure why it is there. > > It is not here https://github.com/openjdk/jdk/blob/master/test/jdk/ProblemList.txt so why is it needed in your PR ? @MBaesken Not sure. It was showing as a conflict due a change from master, so I thought to keep it. Will remove it then. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2257492886 From sroy at openjdk.org Wed Aug 6 15:08:18 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Wed, 6 Aug 2025 15:08:18 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v4] In-Reply-To: References: Message-ID: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> > 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: - all: https://git.openjdk.org/jdk/pull/25332/files - new: https://git.openjdk.org/jdk/pull/25332/files/80a6dba6..e4c076f7 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=03 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=02-03 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod Patch: https://git.openjdk.org/jdk/pull/25332.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/25332/head:pull/25332 PR: https://git.openjdk.org/jdk/pull/25332 From stuefe at openjdk.org Thu Aug 7 05:39:17 2025 From: stuefe at openjdk.org (Thomas Stuefe) Date: Thu, 7 Aug 2025 05:39:17 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v4] In-Reply-To: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> References: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> Message-ID: On Wed, 6 Aug 2025 15:08:18 GMT, Suchismith Roy 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 > Once this issue has been resolved you should not forget to remove the two excludes from jdk/test/ProblemList.txt: > Who? me? Other Reviewers? Strange PR description ;-) ------------- PR Comment: https://git.openjdk.org/jdk/pull/25332#issuecomment-3162562129 From stuefe at openjdk.org Thu Aug 7 06:06:17 2025 From: stuefe at openjdk.org (Thomas Stuefe) Date: Thu, 7 Aug 2025 06:06:17 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v4] In-Reply-To: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> References: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> Message-ID: On Wed, 6 Aug 2025 15:08:18 GMT, Suchismith Roy 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 From stuefe at openjdk.org Thu Aug 7 06:06:18 2025 From: stuefe at openjdk.org (Thomas Stuefe) Date: Thu, 7 Aug 2025 06:06:18 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v4] In-Reply-To: References: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> Message-ID: <9IAX8fOEqLRoOeFdOR1lNTcFTtlipeXO5as2BFahcpg=.b40d3fac-17cd-4f0d-ad6c-5c59902042a4@github.com> On Thu, 7 Aug 2025 05:46:29 GMT, Thomas Stuefe wrote: >> Suchismith Roy has updated the pull request incrementally with one additional commit since the last revision: >> >> Update ProblemList.txt > > 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. Style nit, you may want to group these together into a nice structure, too. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2259142734 From duke at openjdk.org Fri Aug 8 13:09:42 2025 From: duke at openjdk.org (Lei Zhu) Date: Fri, 8 Aug 2025 13:09:42 GMT Subject: jmx-dev RFR: 8362533: Tests sun/management/jmxremote/bootstrap/* duplicate VM flags [v2] In-Reply-To: References: <0XgKkckS1Dk_jyA5ojiQzdopsrs-O5KLu__l7xsQV3g=.da19026b-55a6-4972-9e65-0f712b98ac99@github.com> Message-ID: On Thu, 31 Jul 2025 13:11:13 GMT, Kevin Walls wrote: >> Lei Zhu has updated the pull request incrementally with one additional commit since the last revision: >> >> remove duplicate -cp > > Looks good. > (More than trivial, but good. 8-) ) @kevinjwalls Thanks! ------------- PR Comment: https://git.openjdk.org/jdk/pull/26555#issuecomment-3148349512 From sroy at openjdk.org Mon Aug 25 09:30:56 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Mon, 25 Aug 2025 09:30:56 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v4] In-Reply-To: References: <_h4TBkuFudR5wTGue1oEaeqlZcPZfPnJcWmFdWboZfM=.5676751b-ad3b-4b37-9822-b17464c093dc@github.com> Message-ID: On Thu, 7 Aug 2025 06:01:12 GMT, Thomas Stuefe wrote: >> Suchismith Roy has updated the pull request incrementally with one additional commit since the last revision: >> >> Update ProblemList.txt > > 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(). @tstuefe You mean the first load calculated would be -1 and that would be an issue ? or is it about finding the right delta between measurements ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25332#discussion_r2297589566 From mbaesken at openjdk.org Wed Aug 27 14:30:19 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Wed, 27 Aug 2025 14:30:19 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' Message-ID: When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 208 | pticks->usedKernel = systemTicks; vsscanf usually/normally reads the systemTicks info from /proc file system. see https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 but we never check that the *exact* number of params is read with vsscanf : n = vsscanf(tmp, fmt, args); So potentially we could get a non complete info without systemTicks and the call would still succeed. ------------- Commit messages: - JDK-8366092 Changes: https://git.openjdk.org/jdk/pull/26962/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26962&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8366092 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/26962.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/26962/head:pull/26962 PR: https://git.openjdk.org/jdk/pull/26962 From mbaesken at openjdk.org Wed Aug 27 14:39:01 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Wed, 27 Aug 2025 14:39:01 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: References: Message-ID: > When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : > > /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': > /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] > 208 | pticks->usedKernel = systemTicks; > > > vsscanf usually/normally reads the systemTicks info from /proc file system. see > https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 > but we never check that the *exact* number of params is read with vsscanf : > n = vsscanf(tmp, fmt, args); > So potentially we could get a non complete info without systemTicks and the call would still succeed. Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: init vars so that gcc static analyzer is happy too ------------- Changes: - all: https://git.openjdk.org/jdk/pull/26962/files - new: https://git.openjdk.org/jdk/pull/26962/files/1e9f0572..cb0f8dfc Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=26962&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26962&range=00-01 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/26962.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/26962/head:pull/26962 PR: https://git.openjdk.org/jdk/pull/26962 From kevinw at openjdk.org Wed Aug 27 17:46:41 2025 From: kevinw at openjdk.org (Kevin Walls) Date: Wed, 27 Aug 2025 17:46:41 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: References: Message-ID: <_dzoj_TlgAVspeaYaN5Vaflby5PlodGQ4n3gPXUWIVg=.6933935b-3db2-4430-a5a0-cc44f733dc2b@github.com> On Wed, 27 Aug 2025 14:39:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > init vars so that gcc static analyzer is happy too Yes, seems we have two almost identical read_ticks functions, that's not ideal but hotspot and libmanagement both needed it... Maybe that can be deduplicated in future. 8-) If we now return when read_ticks doesn't read and set both variables, then the "use of uninitialized value" warning becomes incorrect. And with the !=2 check it becomes the same as the other usage, in src/hotspot/os/linux/os_perf_linux.cpp 313 static OSReturn get_jvm_ticks(os::Linux::CPUPerfTicks* pticks) { 314 uint64_t userTicks; 315 uint64_t systemTicks; ... 321 if (read_ticks("/proc/self/stat", &userTicks, &systemTicks) != 2) { 322 return OS_ERR; 323 } ...so does that other code have the same analyzer warning? Ideally I expect we would not change the code just to keep a tool happy, if the warning is not really accurate.... (and presumably the warning might get more accurate in future) ------------- PR Review: https://git.openjdk.org/jdk/pull/26962#pullrequestreview-3161078387 From mbaesken at openjdk.org Thu Aug 28 12:00:44 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Thu, 28 Aug 2025 12:00:44 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: <_dzoj_TlgAVspeaYaN5Vaflby5PlodGQ4n3gPXUWIVg=.6933935b-3db2-4430-a5a0-cc44f733dc2b@github.com> References: <_dzoj_TlgAVspeaYaN5Vaflby5PlodGQ4n3gPXUWIVg=.6933935b-3db2-4430-a5a0-cc44f733dc2b@github.com> Message-ID: On Wed, 27 Aug 2025 17:44:02 GMT, Kevin Walls wrote: > so does that other code have the same analyzer warning? The other one from os_perf_linux.cpp is Hotspot/C++ code and the gcc static analyzer does not work well with C++ (see https://gcc.gnu.org/bugzilla/showdependencytree.cgi?id=97110 ). In the future it will most likely support C++ too. ------------- PR Comment: https://git.openjdk.org/jdk/pull/26962#issuecomment-3233198601 From mbaesken at openjdk.org Thu Aug 28 12:00:46 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Thu, 28 Aug 2025 12:00:46 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: References: Message-ID: On Wed, 27 Aug 2025 14:39:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > init vars so that gcc static analyzer is happy too I think initializing the vars is a good practise. And checking for `!= 2` as you suggested makes sense and should be done here (as we do in Hotspot). ------------- PR Comment: https://git.openjdk.org/jdk/pull/26962#issuecomment-3233205380 From sroy at openjdk.org Fri Aug 29 08:50:37 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Fri, 29 Aug 2025 08:50:37 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v5] In-Reply-To: References: Message-ID: > 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 two additional commits since the last revision: - Thread safety,struct and perfInit() - Thread safety,struct and perfInit() ------------- Changes: - all: https://git.openjdk.org/jdk/pull/25332/files - new: https://git.openjdk.org/jdk/pull/25332/files/e4c076f7..e064140b Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=04 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=03-04 Stats: 121 lines in 1 file changed: 62 ins; 40 del; 19 mod Patch: https://git.openjdk.org/jdk/pull/25332.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/25332/head:pull/25332 PR: https://git.openjdk.org/jdk/pull/25332 From sroy at openjdk.org Fri Aug 29 08:56:56 2025 From: sroy at openjdk.org (Suchismith Roy) Date: Fri, 29 Aug 2025 08:56:56 GMT Subject: jmx-dev RFR: JDK-8030957 - AIX: Implement OperatingSystemMXBean.getSystemCpuLoad() and .getProcessCpuLoad() on AIX [v6] In-Reply-To: References: Message-ID: > 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 with a new target base due to a merge or a rebase. The pull request now contains 12 commits: - Merge branch 'openjdk:master' into cpuprocessload - Thread safety,struct and perfInit() - Thread safety,struct and perfInit() - Update ProblemList.txt - Merge branch 'master' into cpuprocessload - Merge branch 'master' into cpuprocessload - Update UnixOperatingSystem.c - Merge branch 'openjdk:master' into cpuprocessload - cleanup - system cpu load - ... and 2 more: https://git.openjdk.org/jdk/compare/86d6a2e0...46dcf313 ------------- Changes: https://git.openjdk.org/jdk/pull/25332/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25332&range=05 Stats: 100 lines in 2 files changed: 94 ins; 2 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/25332.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/25332/head:pull/25332 PR: https://git.openjdk.org/jdk/pull/25332 From kevinw at openjdk.org Fri Aug 29 10:22:48 2025 From: kevinw at openjdk.org (Kevin Walls) Date: Fri, 29 Aug 2025 10:22:48 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: References: Message-ID: On Wed, 27 Aug 2025 14:39:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > init vars so that gcc static analyzer is happy too Assigning zero to values we are about to set with vsscanf, or are going to ignore, is being added here to keep the analyzer happy. I think we should not do this, and leave the initialization to scanf. (Unless there is some case where it creates a problem.) The extra initialization looks harmless, and while not hugely wasteful, if we do this one, then it starts a long path of adding extra initialization as we have various other examples. "src/hotspot/os/linux/os_perf_linux.cpp" as discussed has the same. Back in "src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c" get_totalticks: 87 static int get_totalticks(int which, ticks *pticks) { ... 89 uint64_t userTicks, niceTicks, systemTicks, idleTicks; 90 uint64_t iowTicks = 0, irqTicks = 0, sirqTicks= 0; ... 97 n = fscanf(fh, "cpu " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 " " 98 DEC_64 " " DEC_64, 99 &userTicks, &niceTicks, &systemTicks, &idleTicks, 100 &iowTicks, &irqTicks, &sirqTicks); This one does not initialize userTicks and 3 others, but does initialize iowTicks and others. We check fscanf result < 4 to mean an error, it failed to read the essential values (that we don't manually initialize). Other examples include src/java.base/unix/native/jspawnhelper/jspawnhelper.c where local int variables are initialized only by a call to scanf, or otherwise ignored. (There are examples where we do initialize such a local int, but that doesn't mean it's necessary.) I'd recommend we don't start initializing things that we can see are either initialized slightly later, or are ignored. ------------- PR Comment: https://git.openjdk.org/jdk/pull/26962#issuecomment-3236525852 From mbaesken at openjdk.org Fri Aug 29 14:11:01 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Fri, 29 Aug 2025 14:11:01 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v3] In-Reply-To: References: Message-ID: > When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : > > /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': > /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] > 208 | pticks->usedKernel = systemTicks; > > > vsscanf usually/normally reads the systemTicks info from /proc file system. see > https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 > but we never check that the *exact* number of params is read with vsscanf : > n = vsscanf(tmp, fmt, args); > So potentially we could get a non complete info without systemTicks and the call would still succeed. Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: Avoid initialization ------------- Changes: - all: https://git.openjdk.org/jdk/pull/26962/files - new: https://git.openjdk.org/jdk/pull/26962/files/cb0f8dfc..daf31fe6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=26962&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26962&range=01-02 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/26962.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/26962/head:pull/26962 PR: https://git.openjdk.org/jdk/pull/26962 From mbaesken at openjdk.org Fri Aug 29 14:11:01 2025 From: mbaesken at openjdk.org (Matthias Baesken) Date: Fri, 29 Aug 2025 14:11:01 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v2] In-Reply-To: References: Message-ID: On Wed, 27 Aug 2025 14:39:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > init vars so that gcc static analyzer is happy too Okay then let's avoid the initialization. ------------- PR Comment: https://git.openjdk.org/jdk/pull/26962#issuecomment-3237165958 From kevinw at openjdk.org Fri Aug 29 14:13:42 2025 From: kevinw at openjdk.org (Kevin Walls) Date: Fri, 29 Aug 2025 14:13:42 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v3] In-Reply-To: References: Message-ID: On Fri, 29 Aug 2025 14:11:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > Avoid initialization Marked as reviewed by kevinw (Reviewer). Thanks! ------------- PR Review: https://git.openjdk.org/jdk/pull/26962#pullrequestreview-3168897601 PR Comment: https://git.openjdk.org/jdk/pull/26962#issuecomment-3237175399 From asteiner at openjdk.org Fri Aug 29 14:26:13 2025 From: asteiner at openjdk.org (Andreas Steiner) Date: Fri, 29 Aug 2025 14:26:13 GMT Subject: jmx-dev RFR: 8366092: [GCC static analyzer] UnixOperatingSystem.c warning: use of uninitialized value 'systemTicks' [v3] In-Reply-To: References: Message-ID: On Fri, 29 Aug 2025 14:11:01 GMT, Matthias Baesken wrote: >> When using gcc static analyzer (-fanalyzer) with gcc 13.2 the following issue is reported : >> >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c: In function 'get_jvmticks': >> /jdk/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c:208:24: warning: use of uninitialized value 'systemTicks' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] >> 208 | pticks->usedKernel = systemTicks; >> >> >> vsscanf usually/normally reads the systemTicks info from /proc file system. see >> https://github.com/openjdk/jdk/blob/45726a1f8b8f76586037867a32b82f8ab9b96937/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c#L163 >> but we never check that the *exact* number of params is read with vsscanf : >> n = vsscanf(tmp, fmt, args); >> So potentially we could get a non complete info without systemTicks and the call would still succeed. > > Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision: > > Avoid initialization Marked as reviewed by asteiner (Author). ------------- PR Review: https://git.openjdk.org/jdk/pull/26962#pullrequestreview-3168939581