From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 01:21:11 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 01:21:11 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports Process CPU usage Message-ID: ?ocess cpu usage inside a container ------------- Commit messages: - 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage inside a container Changes: https://git.openjdk.java.net/jdk/pull/4700/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4700&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8269851 Stats: 41 lines in 1 file changed: 41 ins; 0 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/4700.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4700/head:pull/4700 PR: https://git.openjdk.java.net/jdk/pull/4700 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 01:48:49 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 01:48:49 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports Process CPU usage In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 01:11:00 GMT, xpbob wrote: > ?ocess cpu usage inside a container getProcessCpuLoad return jvm cpu load? 8 core in machine, set 1 core for container? Run same program, the getProcessCpuLoad return the same value? expected same program run in machine,value 0.12 run in 1 core container,value 0.99 ProcessCpuLoad is associative container setting ------------- PR: https://git.openjdk.java.net/jdk/pull/4700 From dholmes at openjdk.java.net Wed Jul 7 02:24:47 2021 From: dholmes at openjdk.java.net (David Holmes) Date: Wed, 7 Jul 2021 02:24:47 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports Process CPU usage In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 01:11:00 GMT, xpbob wrote: > ?ocess cpu usage inside a container @YaSuenag and @jerboaa could you please take a look at this one. ------------- PR: https://git.openjdk.java.net/jdk/pull/4700 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 03:25:49 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 03:25:49 GMT Subject: jmx-dev Withdrawn: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 01:11:00 GMT, xpbob wrote: > ?ocess cpu usage inside a container This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.java.net/jdk/pull/4700 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 04:12:03 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 04:12:03 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: <2SgpJanKLDfP5FQA0GAHrsc8SGOJKCfwj47wqIB6T08=.964a9b22-c6cd-4d52-9e51-e050098c67b5@github.com> On Wed, 7 Jul 2021 04:03:27 GMT, xpbob wrote: > ?ocess cpu usage in containers getProcessCpuLoad return jvm cpu load? 8 core in machine, set 1 core for container? Run same program, the getProcessCpuLoad return the same value? expected same program run in machine,value 0.12 run in 1 core container,value 0.99 ProcessCpuLoad is associative container setting ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 04:12:03 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 04:12:03 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers Message-ID: ?ocess cpu usage in containers ------------- Commit messages: - 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers Changes: https://git.openjdk.java.net/jdk/pull/4702/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8269851 Stats: 41 lines in 1 file changed: 41 ins; 0 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From dholmes at openjdk.java.net Wed Jul 7 04:31:51 2021 From: dholmes at openjdk.java.net (David Holmes) Date: Wed, 7 Jul 2021 04:31:51 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 04:03:27 GMT, xpbob wrote: > ?ocess cpu usage in containers Why did you create a new PR ?? ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From dholmes at openjdk.java.net Wed Jul 7 04:32:53 2021 From: dholmes at openjdk.java.net (David Holmes) Date: Wed, 7 Jul 2021 04:32:53 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 01:11:00 GMT, xpbob wrote: > ?ocess cpu usage inside a container This has moved to https://github.com/openjdk/jdk/pull/4702 ------------- PR: https://git.openjdk.java.net/jdk/pull/4700 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 04:37:51 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 04:37:51 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 04:29:01 GMT, David Holmes wrote: > Why did you create a new PR ?? bug description changed? update the commit info. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From lzang at openjdk.java.net Wed Jul 7 06:34:49 2021 From: lzang at openjdk.java.net (Lin Zang) Date: Wed, 7 Jul 2021 06:34:49 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: <0Yg5MhNiOXFEkhH8_dYEtH9-zQK-qaHGNRafzFGXcJc=.d6ea8e9d-cc24-4165-bd5a-ba375db3fd3f@github.com> On Wed, 7 Jul 2021 04:03:27 GMT, xpbob wrote: > ?ocess cpu usage in containers Hi Bob, I am not a reviewer, just a tiny comments that you may need to remove the unnecessary empty line. Thanks. -Lin src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java line 49: > 47: private long processUsageTicks = 0; // used for process cpu load calculation > 48: private long processTotalTicks = 0; // used for process cpu load calculation > 49: I think this empty line could be removed ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From david.holmes at oracle.com Wed Jul 7 06:48:34 2021 From: david.holmes at oracle.com (David Holmes) Date: Wed, 7 Jul 2021 16:48:34 +1000 Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On 7/07/2021 2:37 pm, xpbob wrote: > On Wed, 7 Jul 2021 04:29:01 GMT, David Holmes wrote: > >> Why did you create a new PR ?? > > bug description changed? > update the commit info. There was no reason to create a new PR. David > ------------- > > PR: https://git.openjdk.java.net/jdk/pull/4702 > From ysuenaga at openjdk.java.net Wed Jul 7 07:55:11 2021 From: ysuenaga at openjdk.java.net (Yasumasa Suenaga) Date: Wed, 7 Jul 2021 07:55:11 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 07:51:49 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > remove empty line In HotSpot, CPU usage for JVM would be calculated at `get_jvm_tickes()` in os_perf_linux.cpp . It refers `/proc/self/stat` - should we refer it in same way? I discussed about similar issue in #4299 , then we came to an agreement that we should refactor that HotSpot and JMX should share the code. Of course you can fix JMX only in this PR, but it still uses different implementation from HotSpot. I prefer to fix it in code consolidation between HotSpot and JMX. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 7 07:55:10 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 7 Jul 2021 07:55:10 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: remove empty line ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/91aa779d..3693793e Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Wed Jul 7 08:34:47 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Wed, 7 Jul 2021 08:34:47 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 07:55:10 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > remove empty line This patch seems fine in principle, but I don't like the duplication. Right now, `getProcessUsageDividesTotal()` and `getUsageDividesTotal()` look almost the same, but use different fields to set. Perhaps pass a parameter whether or not it's a system/process load request and use the different setters accordingly. Same duplication between `getCpuLoad()` and `getProcessCpuLoad()`. The main difference seems to be how `usageNanos` are being retrieved. ------------- Changes requested by sgehwolf (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Wed Jul 7 10:34:51 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Wed, 7 Jul 2021 10:34:51 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 07:50:51 GMT, Yasumasa Suenaga wrote: > In HotSpot, CPU usage for JVM would be calculated at `get_jvm_tickes()` in os_perf_linux.cpp . It refers `/proc/self/stat` - should we refer it in same way? > > I discussed about similar issue in #4299 , then we came to an agreement that we should refactor that HotSpot and JMX should share the code. Of course you can fix JMX only in this PR, but it still uses different implementation from HotSpot. I prefer to fix it in code consolidation between HotSpot and JMX. Yes, we need a bug to track this work (or at least decide on a plan of action - if any). I wouldn't conflate this into this bug, though as it's not clear whether or not JFR/thread dumps should report container values. I'll try to create a bug for this consolidation effort today. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Wed Jul 7 10:37:51 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Wed, 7 Jul 2021 10:37:51 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 08:31:22 GMT, Severin Gehwolf wrote: > This patch seems fine in principle [...] Let me revise this. It looks like imposing CPU limits via cpuset-cpus would go down a path which won't have this fixed with the current patch. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Thu Jul 8 02:48:09 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Thu, 8 Jul 2021 02:48:09 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v3] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: add cpuset-cpus support ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/3693793e..f9dadf7f Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=02 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=01-02 Stats: 52 lines in 1 file changed: 18 ins; 20 del; 14 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Thu Jul 8 02:51:09 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Thu, 8 Jul 2021 02:51:09 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v4] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: remove whitespace ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/f9dadf7f..f5ccb86c Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=03 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=02-03 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Thu Jul 8 03:50:51 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Thu, 8 Jul 2021 03:50:51 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v2] In-Reply-To: References: Message-ID: <8bhPcHa3Opgk3zDJwZ3i0ahdnflKyy5A5G-0DgRU58k=.357d0227-6280-46c0-b8bb-60c5e1841755@github.com> On Wed, 7 Jul 2021 10:34:51 GMT, Severin Gehwolf wrote: > > This patch seems fine in principle [...] > > Let me revise this. It looks like imposing CPU limits via cpuset-cpus would go down a path which won't have this fixed with the current patch. use (getProcessCpuLoad0() * totalCPUs / containerCPUs) for CPU limits via cpuset-cpus ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Fri Jul 9 14:22:54 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Fri, 9 Jul 2021 14:22:54 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v4] In-Reply-To: References: Message-ID: On Thu, 8 Jul 2021 02:51:09 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > remove whitespace Thanks for the update. `getProcessCpuLoad()` and `getCpuLoad()` looks way too similar to me. Is there a way to make them more generic and do the process vs. system paths as needed? I think there is. ------------- Changes requested by sgehwolf (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Mon Jul 12 03:24:12 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Mon, 12 Jul 2021 03:24:12 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v5] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: use same path for cpuload ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/f5ccb86c..90aa3c6b Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=04 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=03-04 Stats: 118 lines in 1 file changed: 44 ins; 51 del; 23 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Mon Jul 12 03:49:50 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Mon, 12 Jul 2021 03:49:50 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v4] In-Reply-To: References: Message-ID: On Fri, 9 Jul 2021 14:19:42 GMT, Severin Gehwolf wrote: > Thanks for the update. `getProcessCpuLoad()` and `getCpuLoad()` looks way too similar to me. Is there a way to make them more generic and do the process vs. system paths as needed? I think there is. use getCpuLoadWithTarget for process and system ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Mon Jul 12 13:22:59 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Mon, 12 Jul 2021 13:22:59 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v4] In-Reply-To: References: Message-ID: On Mon, 12 Jul 2021 03:46:23 GMT, xpbob wrote: > > Thanks for the update. `getProcessCpuLoad()` and `getCpuLoad()` looks way too similar to me. Is there a way to make them more generic and do the process vs. system paths as needed? I think there is. > > use getCpuLoadWithTarget for process and system Thanks. We are getting there. I've proposed a PR to your branch which makes this a bit easier to read: https://github.com/xpbob/jdk/pull/1 If you merge that it'll show up in this PR. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Tue Jul 13 03:49:21 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Tue, 13 Jul 2021 03:49:21 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v6] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: Refactor process/system cpu load calculation ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/90aa3c6b..e6849957 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=05 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=04-05 Stats: 226 lines in 1 file changed: 120 ins; 99 del; 7 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Tue Jul 13 05:19:25 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Tue, 13 Jul 2021 05:19:25 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v7] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: Set 1.0 for cpu set max ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/e6849957..fdd17d50 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=06 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=05-06 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Tue Jul 13 06:03:53 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Tue, 13 Jul 2021 06:03:53 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v7] In-Reply-To: References: Message-ID: On Tue, 13 Jul 2021 05:19:25 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Set 1.0 for cpu set max > > > Thanks for the update. `getProcessCpuLoad()` and `getCpuLoad()` looks way too similar to me. Is there a way to make them more generic and do the process vs. system paths as needed? I think there is. > > > > > > use getCpuLoadWithTarget for process and system > > Thanks. We are getting there. I've proposed a PR to your branch which makes this a bit easier to read: > [xpbob#1](https://github.com/xpbob/jdk/pull/1) > > If you merge that it'll show up in this PR. Thank you so much @jerboaa . Code has been merged. I tested the following cgroup scenario on Linux/x64 and all passed. cpu-quota=50000 cpu-period=50000 cpuset-cpus=0-2 cpu.shares=2048 cpuset-cpus=3 ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Tue Jul 13 13:09:55 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Tue, 13 Jul 2021 13:09:55 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v7] In-Reply-To: References: Message-ID: On Tue, 13 Jul 2021 05:19:25 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Set 1.0 for cpu set max https://github.com/jerboaa/jdk/actions/runs/1026610314 is a pre-integration run of this. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Tue Jul 13 15:12:59 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Tue, 13 Jul 2021 15:12:59 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v7] In-Reply-To: References: Message-ID: On Tue, 13 Jul 2021 05:19:25 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Set 1.0 for cpu set max Except for the missing comments in the new code blocks this looks good to me. src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java line 98: > 96: hostTicks = hostTicks * containerCPUs / totalCPUs; > 97: return getUsageDividesTotal(cpuUsageSupplier().getAsLong(), hostTicks); > 98: } else { The old code had these comments here. We should add them as they're still relevant: // If CPU quotas and shares are not active then find the average system load for // all online CPUs that are allowed to run this container. // If the cpuset is the same as the host's one there is no need to iterate over each CPU src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java line 106: > 104: cpuSet = containerMetrics.getCpuSetCpus(); > 105: } > 106: if (cpuSet == null) { Please add the comment as it was in the original code: // cgroups is mounted, but CPU resource is not limited. // We can assume the VM is run on the host CPUs. ------------- Marked as reviewed by sgehwolf (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 14 04:00:39 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 14 Jul 2021 04:00:39 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v8] In-Reply-To: References: Message-ID: > ?ocess cpu usage in containers xpbob has updated the pull request incrementally with one additional commit since the last revision: Add comments ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/4702/files - new: https://git.openjdk.java.net/jdk/pull/4702/files/fdd17d50..0f43d5dc Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=07 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4702&range=06-07 Stats: 7 lines in 1 file changed: 7 ins; 0 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/4702.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702 PR: https://git.openjdk.java.net/jdk/pull/4702 From sgehwolf at openjdk.java.net Wed Jul 14 07:41:15 2021 From: sgehwolf at openjdk.java.net (Severin Gehwolf) Date: Wed, 14 Jul 2021 07:41:15 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v8] In-Reply-To: References: Message-ID: On Wed, 14 Jul 2021 04:00:39 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Add comments Still looks good. ------------- Marked as reviewed by sgehwolf (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Fri Jul 16 02:15:11 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Fri, 16 Jul 2021 02:15:11 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v8] In-Reply-To: References: Message-ID: <__7USH80DXNvB-sGRUDc71KwwGqn9-KEUyXXHOV0hqk=.7ecbca8f-281b-4ac8-b555-50a984b664e7@github.com> On Wed, 14 Jul 2021 04:00:39 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Add comments May I get a second review for this change? Thanks. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From jiefu at openjdk.java.net Wed Jul 28 02:37:28 2021 From: jiefu at openjdk.java.net (Jie Fu) Date: Wed, 28 Jul 2021 02:37:28 GMT Subject: jmx-dev RFR: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers [v8] In-Reply-To: References: Message-ID: On Wed, 14 Jul 2021 04:00:39 GMT, xpbob wrote: >> ?ocess cpu usage in containers > > xpbob has updated the pull request incrementally with one additional commit since the last revision: > > Add comments Will sponsor it tomorrow if there is no objection. Thanks. ------------- PR: https://git.openjdk.java.net/jdk/pull/4702 From github.com+7837910+xpbob at openjdk.java.net Wed Jul 28 23:15:36 2021 From: github.com+7837910+xpbob at openjdk.java.net (xpbob) Date: Wed, 28 Jul 2021 23:15:36 GMT Subject: jmx-dev Integrated: 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers In-Reply-To: References: Message-ID: On Wed, 7 Jul 2021 04:03:27 GMT, xpbob wrote: > ?ocess cpu usage in containers This pull request has now been integrated. Changeset: 25f00d78 Author: bobpengxie Committer: Jie Fu URL: https://git.openjdk.java.net/jdk/commit/25f00d787cf56f6cdca6949115d04e7d8e675554 Stats: 218 lines in 1 file changed: 137 ins; 78 del; 3 mod 8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers Co-authored-by: Severin Gehwolf Reviewed-by: sgehwolf ------------- PR: https://git.openjdk.java.net/jdk/pull/4702