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

HotSpot Not Identifying it is Running in a Container

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b15
    • CPU:
      x86_64
    • OS:
      linux

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        Docker Desktop 2.3.0.4 for Mac OS.
        Docker Desktop 2.3.0.4 for Windows 10

        A DESCRIPTION OF THE PROBLEM :
        When running the JVM (15-ea, 16-ea) inside a container on Docker Desktop for Windows (non-WLS2) or Mac OS, the JVM cannot correctly identify it is running in a container, and therefore returns incorrect data about available processors.

        Docker Desktop (Windows/Mac) ships a lightweight VM based on LinuxKit with kernel 4.x. When running Docker Desktop for Windows with WSL2 support enabled, this issue does not occur.

        This issue was not observed with any release between 14 and 11.

        More details on the output of cgroups inside the container running on Docker Desktop for Mac OS:

        / # docker run --cpus=1 -ti openjdk:15-jdk-slim cat /proc/self/mountinfo
        557 328 0:123 / / rw,relatime master:126 - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/JOQDF3QYKG2BTIR65TELMY6SPN:/var/lib/docker/overlay2/l/KTLKUWGZ4YWDDTHG2BIV7DT2X5:/var/lib/docker/overlay2/l/5ZIBLJPA22CVU5KJMTWHEUFOPD:/var/lib/docker/overlay2/l/IXN4HJHDDFBXWLFKL4QA43533J:/var/lib/docker/overlay2/l/TEBUGLOHYX4U675SMGZOGLH3ZU,upperdir=/var/lib/docker/overlay2/83e3e2ec3cd49f355d0be00a6c5550569053676ff6952e943ac3b7f862ec962e/diff,workdir=/var/lib/docker/overlay2/83e3e2ec3cd49f355d0be00a6c5550569053676ff6952e943ac3b7f862ec962e/work
        558 557 0:125 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
        559 557 0:126 / /dev rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755
        560 559 0:127 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
        561 557 0:128 / /sys ro,nosuid,nodev,noexec,relatime - sysfs sysfs ro
        562 561 0:129 / /sys/fs/cgroup ro,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755
        563 562 0:29 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/cpuset ro,nosuid,nodev,noexec,relatime master:18 - cgroup cpuset rw,cpuset
        564 562 0:30 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/cpu ro,nosuid,nodev,noexec,relatime master:19 - cgroup cpu rw,cpu
        565 562 0:31 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/cpuacct ro,nosuid,nodev,noexec,relatime master:20 - cgroup cpuacct rw,cpuacct
        566 562 0:32 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/blkio ro,nosuid,nodev,noexec,relatime master:21 - cgroup blkio rw,blkio
        567 562 0:33 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime master:22 - cgroup memory rw,memory
        568 562 0:34 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime master:23 - cgroup devices rw,devices
        569 562 0:35 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/freezer ro,nosuid,nodev,noexec,relatime master:24 - cgroup freezer rw,freezer
        570 562 0:36 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/net_cls ro,nosuid,nodev,noexec,relatime master:25 - cgroup net_cls rw,net_cls
        571 562 0:37 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/perf_event ro,nosuid,nodev,noexec,relatime master:26 - cgroup perf_event rw,perf_event
        572 562 0:38 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/net_prio ro,nosuid,nodev,noexec,relatime master:27 - cgroup net_prio rw,net_prio
        573 562 0:39 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/hugetlb ro,nosuid,nodev,noexec,relatime master:28 - cgroup hugetlb rw,hugetlb
        574 562 0:40 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/pids ro,nosuid,nodev,noexec,relatime master:29 - cgroup pids rw,pids
        575 562 0:41 / /sys/fs/cgroup/rdma ro,nosuid,nodev,noexec,relatime master:30 - cgroup rdma rw,rdma
        576 562 0:42 /docker/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63 /sys/fs/cgroup/systemd ro,nosuid,nodev,noexec,relatime master:31 - cgroup cgroup rw,name=systemd
        577 559 0:124 / /dev/mqueue rw,nosuid,nodev,noexec,relatime - mqueue mqueue rw
        578 559 0:130 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,size=65536k
        579 557 254:1 /docker/containers/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63/resolv.conf /etc/resolv.conf rw,relatime - ext4 /dev/vda1 rw
        580 557 254:1 /docker/containers/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63/hostname /etc/hostname rw,relatime - ext4 /dev/vda1 rw
        581 557 254:1 /docker/containers/b7dabdf30d0a4dab49b924ee497d83a4dcf008f9cf9423b085be0f9fced35f63/hosts /etc/hosts rw,relatime - ext4 /dev/vda1 rw
        329 559 0:127 /0 /dev/console rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
        330 558 0:125 /bus /proc/bus ro,relatime - proc proc rw
        331 558 0:125 /fs /proc/fs ro,relatime - proc proc rw
        332 558 0:125 /irq /proc/irq ro,relatime - proc proc rw
        333 558 0:125 /sys /proc/sys ro,relatime - proc proc rw
        334 558 0:125 /sysrq-trigger /proc/sysrq-trigger ro,relatime - proc proc rw
        357 558 0:131 / /proc/acpi ro,relatime - tmpfs tmpfs ro
        358 558 0:126 /null /proc/kcore rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755
        359 558 0:126 /null /proc/keys rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755
        360 558 0:126 /null /proc/timer_list rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755
        361 558 0:126 /null /proc/sched_debug rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755
        362 561 0:132 / /sys/firmware ro,relatime - tmpfs tmpfs ro

        / # docker run --cpus=1 -ti openjdk:15-jdk-slim cat /proc/cgroups
        #subsys_name hierarchy num_cgroups enabled
        cpuset 1 28 1
        cpu 2 28 1
        cpuacct 3 28 1
        blkio 4 28 1
        memory 5 32 1
        devices 6 28 1
        freezer 7 28 1
        net_cls 8 28 1
        perf_event 9 28 1
        net_prio 10 28 1
        hugetlb 11 28 1
        pids 12 28 1
        rdma 13 4 1


        / # docker run --cpus=1 -ti openjdk:15-jdk-slim cat /proc/self/cgroup
        14:name=systemd:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        13:rdma:/
        12:pids:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        11:hugetlb:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        10:net_prio:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        9:perf_event:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        8:net_cls:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        7:freezer:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        6:devices:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        5:memory:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        4:blkio:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        3:cpuacct:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        2:cpu:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975
        1:cpuset:/docker/4e650b036993e443ded0122be926a3766a731fdd51d08520bf307c1006219975




        Discussion: https://mail.openjdk.java.net/pipermail/discuss/2020-August/005580.html

        REGRESSION : Last worked in version 14.0.2

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Install Docker Desktop for Windows, ensure Hyper-V is enabled on Windows, and that WSL2 support is disabled in Docker Desktop preferences.

        Install Docker Desktop for Mac OS.

        Run the following command:

        $ docker run --cpus=1 --memory=256m -ti openjdk:15-jdk-slim java -XX:+PrintFlagsFinal -version 2>&1 | grep Use | grep GC

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        / # docker run --cpus=1 --memory=256m -ti openjdk:14-jdk-slim java -XX:+PrintFlagsFinal -version 2>&1 | grep Use | grep GC
             bool UseAdaptiveGCBoundary = false {product} {default}
             bool UseAdaptiveSizeDecayMajorGCCost = true {product} {default}
             bool UseAdaptiveSizePolicyWithSystemGC = false {product} {default}
             bool UseDynamicNumberOfGCThreads = true {product} {default}
             bool UseG1GC = false {product} {default}
             bool UseGCOverheadLimit = true {product} {default}
             bool UseMaximumCompactionOnSystemGC = true {product} {default}
             bool UseParallelGC = false {product} {default}
             bool UseParallelOldGC = false {product} {default}
             bool UseSerialGC = true {product} {ergonomic}
        ACTUAL -
        / # docker run --cpus=1 --memory=256m -ti openjdk:15-jdk-slim java -XX:+PrintFlagsFinal -version 2>&1 | grep Use | grep GC
             bool UseAdaptiveSizeDecayMajorGCCost = true {product} {default}
             bool UseAdaptiveSizePolicyWithSystemGC = false {product} {default}
             bool UseDynamicNumberOfGCThreads = true {product} {default}
             bool UseG1GC = true {product} {ergonomic}
             bool UseGCOverheadLimit = true {product} {default}
             bool UseMaximumCompactionOnSystemGC = true {product} {default}
             bool UseParallelGC = false {product} {default}
             bool UseSerialGC = false {product} {default}
             bool UseShenandoahGC = false {product} {default}
             bool UseZGC = false {product} {default}

        CUSTOMER SUBMITTED WORKAROUND :
        Use the flag ActiveProcessorCount to force the count to 1.

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                bobv Bob Vandette (Inactive)
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: