Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8212528

Wrong cgroup subsystem being used for some CPU Container Metrics

    Details

    • Resolved In Build:
      b13

      Backports

        Description

        Some of the CPU Metrics being reported on Linux are being incorrectly reported on some Linux distributions. The cpu metrics listed below are being referenced via the cpuacct subsystem. This works in most cases due to the fact that the cpuacct and cpu subsystems are symbolically linked to the same directory. This is not the case on all Linux distributions.

        The configuration where Is first discovered this problem running docker on a Mac and
        running a Linux container under docker.

        A suggested fix is listed below:

        diff --git a/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java b/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java
        --- a/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java
        +++ b/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java
        @@ -299,15 +299,15 @@
         
         
             public long getCpuPeriod() {
        - return SubSystem.getLongValue(cpuacct, "cpu.cfs_period_us");
        + return SubSystem.getLongValue(cpu, "cpu.cfs_period_us");
             }
         
             public long getCpuQuota() {
        - return SubSystem.getLongValue(cpuacct, "cpu.cfs_quota_us");
        + return SubSystem.getLongValue(cpu, "cpu.cfs_quota_us");
             }
         
             public long getCpuShares() {
        - long retval = SubSystem.getLongValue(cpuacct, "cpu.shares");
        + long retval = SubSystem.getLongValue(cpu, "cpu.shares");
                 if (retval == 0 || retval == 1024)
                     return -1;
                 else
        @@ -315,15 +315,15 @@
             }
         
             public long getCpuNumPeriods() {
        - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_periods");
        + return SubSystem.getLongEntry(cpu, "cpu.stat", "nr_periods");
             }
         
             public long getCpuNumThrottled() {
        - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_throttled");
        + return SubSystem.getLongEntry(cpu, "cpu.stat", "nr_throttled");
             }
         
             public long getCpuThrottledTime() {
        - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "throttled_time");
        + return SubSystem.getLongEntry(cpu, "cpu.stat", "throttled_time");
             }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  bobv Bob Vandette
                  Reporter:
                  bobv Bob Vandette
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: