Skip to content

Re-enable cgroup test for s390x #189

Closed

Description

@omajid

Cgroup support is currently not implemented on mono (used on s390x). We are going to, shortly, disable that test on s390x.

But upstream is working on a fix, we should enable the test for s390x when mono gets support for cgroups.

Activity

  1. omajid commented on Oct 27, 2022

    @omajid
    MemberAuthor

    This was fixed in mono with dotnet/runtime#74237 and should be a part of 7.0 now. This test is now expected to pass on 7.0 for mono runtimes too.

  2. omajid commented on Oct 27, 2022

    @omajid
    MemberAuthor

    I have run this test on ppc64le and s390x now and both fail:

    s390x

    + cat /proc/self/mountinfo
    21 95 0:20 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw,seclabel
    22 95 0:5 / /proc rw,nosuid,nodev,noexec,relatime shared:26 - proc proc rw
    23 95 0:6 / /dev rw,nosuid shared:22 - devtmpfs devtmpfs rw,seclabel,size=16381520k,nr_inodes=4095380,mode=755
    24 21 0:7 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:3 - securityfs securityfs rw
    25 23 0:21 / /dev/shm rw,nosuid,nodev shared:23 - tmpfs tmpfs rw,seclabel
    26 23 0:22 / /dev/pts rw,nosuid,noexec,relatime shared:24 - devpts devpts rw,seclabel,gid=5,mode=620,ptmxmode=000
    27 95 0:23 / /run rw,nosuid,nodev shared:25 - tmpfs tmpfs rw,seclabel,mode=755
    28 21 0:24 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:4 - tmpfs tmpfs ro,seclabel,mode=755
    29 28 0:25 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:5 - cgroup cgroup rw,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
    30 21 0:26 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:17 - pstore pstore rw,seclabel
    31 21 0:27 / /sys/fs/bpf rw,nosuid,nodev,noexec,relatime shared:18 - bpf bpf rw,mode=700
    32 28 0:28 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,seclabel,perf_event
    33 28 0:29 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 - cgroup cgroup rw,seclabel,cpu,cpuacct
    34 28 0:30 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:8 - cgroup cgroup rw,seclabel,cpuset
    35 28 0:31 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:9 - cgroup cgroup rw,seclabel,net_cls,net_prio
    36 28 0:32 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,seclabel,rdma
    37 28 0:33 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,seclabel,pids
    38 28 0:34 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:12 - cgroup cgroup rw,seclabel,freezer
    39 28 0:35 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,seclabel,blkio
    40 28 0:36 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,seclabel,hugetlb
    41 28 0:37 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,seclabel,memory
    42 28 0:38 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,seclabel,devices
    43 21 0:12 / /sys/kernel/tracing rw,relatime shared:19 - tracefs none rw,seclabel
    92 21 0:39 / /sys/kernel/config rw,relatime shared:20 - configfs configfs rw
    95 1 253:3 / / rw,relatime shared:1 - xfs /dev/mapper/rhel_dotnet1-root rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    44 21 0:19 / /sys/fs/selinux rw,relatime shared:21 - selinuxfs selinuxfs rw
    45 22 0:40 / /proc/sys/fs/binfmt_misc rw,relatime shared:27 - autofs systemd-1 rw,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=25413
    47 23 0:41 / /dev/hugepages rw,relatime shared:28 - hugetlbfs hugetlbfs rw,seclabel,pagesize=1M
    46 23 0:18 / /dev/mqueue rw,relatime shared:29 - mqueue mqueue rw,seclabel
    48 21 0:8 / /sys/kernel/debug rw,relatime shared:30 - debugfs debugfs rw,seclabel
    112 95 253:3 /mnt/ramdisk /jck rw,relatime shared:1 - xfs /dev/mapper/rhel_dotnet1-root rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    115 95 253:5 / /mnt/raid rw,relatime shared:62 - xfs /dev/mapper/rhel_dotnet1-mnt_raid rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    118 95 253:5 /home /home rw,relatime shared:62 - xfs /dev/mapper/rhel_dotnet1-mnt_raid rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    121 95 253:5 /home/tester/vm-shared /mnt/shared rw,relatime shared:62 - xfs /dev/mapper/rhel_dotnet1-mnt_raid rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    124 95 253:5 /libvirt-images /var/lib/libvirt/images rw,relatime shared:62 - xfs /dev/mapper/rhel_dotnet1-mnt_raid rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    127 95 253:1 / /boot rw,relatime shared:67 - xfs /dev/mapper/mpatha1 rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    278 95 0:42 / /var/lib/nfs/rpc_pipefs rw,relatime shared:106 - rpc_pipefs sunrpc rw
    368 27 0:43 / /run/user/1001 rw,nosuid,nodev,relatime shared:192 - tmpfs tmpfs rw,seclabel,size=3279968k,mode=700,uid=1001,gid=1001
    + cat /proc/self/cgroup
    12:devices:/user.slice
    11:memory:/user.slice/user-1001.slice/session-3068.scope
    10:hugetlb:/
    9:blkio:/user.slice
    8:freezer:/
    7:pids:/user.slice/user-1001.slice/session-3068.scope
    6:rdma:/
    5:net_cls,net_prio:/
    4:cpuset:/
    3:cpu,cpuacct:/user.slice
    2:perf_event:/
    1:name=systemd:/user.slice/user-1001.slice/session-3068.scope
    ++ stat -f -c %T /sys/fs/cgroup
    + [[ tmpfs == \c\g\r\o\u\p\2\f\s ]]
    ++ command -v systemctl
    + '[' -z /usr/bin/systemctl ']'
    + dotnet publish
    
    Welcome to .NET 7.0!
    ---------------------
    SDK Version: 7.0.100
    
    ----------------
    Installed an ASP.NET Core HTTPS development certificate.
    To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
    Learn about HTTPS: https://aka.ms/dotnet-https
    ----------------
    Write your first app: https://aka.ms/dotnet-hello-world
    Find out what's new: https://aka.ms/dotnet-whats-new
    Explore documentation: https://aka.ms/dotnet-docs
    Report issues and find source on GitHub: https://github.com/dotnet/core
    Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
    --------------------------------------------------------------------------------------
    MSBuild version 17.4.0+18d5aef85 for .NET
      Determining projects to restore...
      Restored /home/tester/omajid/dotnet-regular-tests/cgroup-limit/cgroup-limit.csproj (in 141 ms).
      cgroup-limit -> /home/tester/omajid/dotnet-regular-tests/cgroup-limit/bin/Debug/net7.0/cgroup-limit.dll
      cgroup-limit -> /home/tester/omajid/dotnet-regular-tests/cgroup-limit/bin/Debug/net7.0/publish/
    + SYSTEMD_RUN=systemd-run
    + '[' 1001 '!=' 0 ']'
    + grep -q cpu /sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/cgroup.controllers
    grep: /sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/cgroup.controllers: No such file or directory
    + SYSTEMD_RUN='sudo -n systemd-run'
    + mapfile -t DOTNET_LIMITS
    ++ sudo -n systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=100M bin/Debug/net7.0/cgroup-limit
    + '[' Limits: == Limits: ']'
    + '[' 1 == 1 ']'
    + '[' 209715200 -lt 100000000 ']'
    + printf 'error: unexpected limits: %s\n' Limits: 1 209715200
    error: unexpected limits: Limits:
    error: unexpected limits: 1
    error: unexpected limits: 209715200
    + echo '.NET Runtime uses cgroup limits FAIL'
    .NET Runtime uses cgroup limits FAIL
    + exit 1
    

    ppc64le

    $ ./test.sh 
    + cat /proc/self/mountinfo
    20 94 0:19 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw,seclabel
    21 94 0:5 / /proc rw,nosuid,nodev,noexec,relatime shared:26 - proc proc rw
    22 94 0:6 / /dev rw,nosuid shared:22 - devtmpfs devtmpfs rw,seclabel,size=7776256k,nr_inodes=121504,mode=755
    23 20 0:7 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:3 - securityfs securityfs rw
    24 22 0:20 / /dev/shm rw,nosuid,nodev shared:23 - tmpfs tmpfs rw,seclabel
    25 22 0:21 / /dev/pts rw,nosuid,noexec,relatime shared:24 - devpts devpts rw,seclabel,gid=5,mode=620,ptmxmode=000
    26 94 0:22 / /run rw,nosuid,nodev shared:25 - tmpfs tmpfs rw,seclabel,mode=755
    27 20 0:23 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:4 - tmpfs tmpfs ro,seclabel,mode=755
    28 27 0:24 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:5 - cgroup cgroup rw,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
    29 20 0:25 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:17 - pstore pstore rw,seclabel
    30 20 0:26 / /sys/fs/bpf rw,nosuid,nodev,noexec,relatime shared:18 - bpf bpf rw,mode=700
    31 27 0:27 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,seclabel,devices
    32 27 0:28 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:7 - cgroup cgroup rw,seclabel,freezer
    33 27 0:29 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:8 - cgroup cgroup rw,seclabel,net_cls,net_prio
    34 27 0:30 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:9 - cgroup cgroup rw,seclabel,pids
    35 27 0:31 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,seclabel,cpuset
    36 27 0:32 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,seclabel,memory
    37 27 0:33 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:12 - cgroup cgroup rw,seclabel,cpu,cpuacct
    38 27 0:34 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,seclabel,perf_event
    39 27 0:35 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,seclabel,hugetlb
    40 27 0:36 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,seclabel,rdma
    41 27 0:37 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,seclabel,blkio
    42 20 0:12 / /sys/kernel/tracing rw,relatime shared:19 - tracefs none rw,seclabel
    91 20 0:38 / /sys/kernel/config rw,relatime shared:20 - configfs configfs rw
    94 1 253:0 / / rw,relatime shared:1 - xfs /dev/mapper/rhel_ibm--p8--kvm--07--guest--05-root rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    43 20 0:18 / /sys/fs/selinux rw,relatime shared:21 - selinuxfs selinuxfs rw
    44 22 0:17 / /dev/mqueue rw,relatime shared:27 - mqueue mqueue rw,seclabel
    45 21 0:39 / /proc/sys/fs/binfmt_misc rw,relatime shared:28 - autofs systemd-1 rw,fd=36,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=16666
    46 20 0:8 / /sys/kernel/debug rw,relatime shared:29 - debugfs debugfs rw,seclabel
    47 94 252:2 / /boot rw,relatime shared:30 - xfs /dev/vda2 rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    112 94 253:2 / /home rw,relatime shared:61 - xfs /dev/mapper/rhel_ibm--p8--kvm--07--guest--05-home rw,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota
    395 26 0:42 / /run/user/0 rw,nosuid,nodev,relatime shared:245 - tmpfs tmpfs rw,seclabel,size=1565888k,mode=700
    449 26 0:43 / /run/user/1001 rw,nosuid,nodev,relatime shared:234 - tmpfs tmpfs rw,seclabel,size=1565888k,mode=700,uid=1001,gid=1001
    + cat /proc/self/cgroup
    12:blkio:/user.slice
    11:rdma:/
    10:hugetlb:/
    9:perf_event:/
    8:cpu,cpuacct:/user.slice
    7:memory:/user.slice/user-1001.slice/session-7.scope
    6:cpuset:/
    5:pids:/user.slice/user-1001.slice/session-7.scope
    4:net_cls,net_prio:/
    3:freezer:/
    2:devices:/user.slice
    1:name=systemd:/user.slice/user-1001.slice/session-7.scope
    ++ stat -f -c %T /sys/fs/cgroup
    + [[ tmpfs == \c\g\r\o\u\p\2\f\s ]]
    ++ command -v systemctl
    + '[' -z /usr/bin/systemctl ']'
    + dotnet publish
    MSBuild version 17.4.0+18d5aef85 for .NET
      Determining projects to restore...
      Restored /home/dotnet/dotnet-regular-tests/cgroup-limit/cgroup-limit.csproj (in 320 ms).
      cgroup-limit -> /home/dotnet/dotnet-regular-tests/cgroup-limit/bin/Debug/net7.0/cgroup-limit.dll
      cgroup-limit -> /home/dotnet/dotnet-regular-tests/cgroup-limit/bin/Debug/net7.0/publish/
    + SYSTEMD_RUN=systemd-run
    + '[' 1001 '!=' 0 ']'
    + grep -q cpu /sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/cgroup.controllers
    grep: /sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/cgroup.controllers: No such file or directory
    + SYSTEMD_RUN='sudo -n systemd-run'
    + mapfile -t DOTNET_LIMITS
    ++ sudo -n systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=100M bin/Debug/net7.0/cgroup-limit
    + '[' Limits: == Limits: ']'
    + '[' 1 == 1 ']'
    + '[' 209715200 -lt 100000000 ']'
    + printf 'error: unexpected limits: %s\n' Limits: 1 209715200
    error: unexpected limits: Limits:
    error: unexpected limits: 1
    error: unexpected limits: 209715200
    + echo '.NET Runtime uses cgroup limits FAIL'
    .NET Runtime uses cgroup limits FAIL
    + exit 1
    

    @tmds @uweigand @janani66 Does this seem expected? Any idea what's going on? Is it a test bug or a bug in mono?

  3. tmds commented on Oct 27, 2022

    @tmds
    Member

    209715200 -lt 100000000

    means GC.GetGCMemoryInfo().TotalAvailableMemoryBytes returns exactly 200MB, which is more than the 100MB limit we've set.

    If you vary the MemoryLimit, how does TotalAvailableMemoryBytes behave?

  4. janani66 commented on Oct 27, 2022

    @janani66
    Contributor

    @tmds Well changing the MemoryLimit doesn't seem to change anything on ppc64le running .NET7 RC2 code

    [cgroup-limit]#systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=250M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    209715200

    [cgroup-limit]#systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=200M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    209715200

    [cgroup-limit]#systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=100M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    209715200

  5. janani66 commented on Oct 27, 2022

    @janani66
    Contributor

    BTW, I am testing with .NET7.0 RC2 which has:
    [release/7.0] [mono] Determine any memory/CPU limitations from sysfs cgroup#74881 (dotnet/runtime#74881)

    But it does not have:
    [release/7.0][mono][sgen] Update memory load information after world is resumed #76534 (dotnet/runtime#76534).
    Is this second commit also needed for Cgroup Limits to work? Note: This second commit dotnet/runtime#76534 landed in the .NET7 GA code

  6. tmds commented on Oct 28, 2022

    @tmds
    Member

    @omajid this is not a blocker for 7.0, right?

  7. uweigand commented on Oct 28, 2022

    @uweigand

    Hmm. Looking at the sources, I see:

                                    restricted_limit = (3 * restricted_limit) / 4;  /* Use 75% limit of container */
                            }
                    }
                    return (restricted_limit < MINMEMSZ ? MINMEMSZ :        /* Use at least 20MB */
                            (restricted_limit < memsize ? restricted_limit : memsize));
    

    However, the variable MINMEMSZ is actually defined as:

    #define MINMEMSZ 209715200      /* Minimum restricted memory size */
    

    So I believe the intent was to allow using "75% of the container limit, but at least 20MB" - but the code actually does "75% of the container limit, but at least 200MB". This seems to match the measurements above. @janani66 can you try larger values? E.g. with 300MB container limit, you should be seeing more than 200MB.

    @nealef, I'm assuming the comment is correct and this should really be 20MB instead of 200MB? I cannot find either limit in the CoreCLR implementation at first glance, so I'm not sure where these values come from ...

  8. uweigand commented on Oct 28, 2022

    @uweigand

    @omajid if changing the MINMEMSZ variable fixes this, is this something that could be done for GA?

  9. janani66 commented on Oct 28, 2022

    @janani66
    Contributor

    @uweigand -- you nailed it

    [root@ltcden12-lp6 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=300M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    235929600
    [root@ltcden12-lp6 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=350M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    275251200

  10. omajid commented on Oct 28, 2022

    @omajid
    MemberAuthor

    @omajid this is not a blocker for 7.0, right?

    IMO, It's not a blocker. Most importantly, it's not a regression. It only affects mono (where cgroup was previously compleletey broken). If we have a fix, we can take it, or we can wait for a fix to flow in through a monthly servicing update.

    @omajid if changing the MINMEMSZ variable fixes this, is this something that could be done for GA?

    Yes. We don't have the final builds GA yet so we have some time to tweak things. Since this only affects mono, if you and @janani66 agree on a fix, We can include it. It would be nice to send a PR to dotnet/runtime for 7.0 though (for review/sanity-check and reduce our maintenance burden down the road).

  11. uweigand commented on Oct 28, 2022

    @uweigand

    I've now found the corresponding place in CoreCLR, and it is indeed using 20 MB, not 200 MB. See the comment here:
    https://github.com/dotnet/runtime/blob/a6f4527ebf2c3faa5b9f55e8a7acb12df4571425/src/coreclr/gc/gcpriv.h#L4062-L4067
    and the implementation at around line 45176 in src/coreclr/gc/gc.cpp:

        // If the hard limit is specified, the user is saying even if the process is already
        // running in a container, use this limit for the GC heap.
        if (gc_heap::heap_hard_limit)
        {
    #ifdef FEATURE_EVENT_TRACE
            gc_heap::hard_limit_config_p = true;
    #endif //FEATURE_EVENT_TRACE
        }
        else
        {
            if (gc_heap::is_restricted_physical_mem)
            {
                uint64_t physical_mem_for_gc = gc_heap::total_physical_mem * (uint64_t)75 / (uint64_t)100;
                gc_heap::heap_hard_limit = (size_t)max ((20 * 1024 * 1024), physical_mem_for_gc);
            }
        }
    

    The attached patch implements the obvious fix to change to 20 MB in Mono as well:
    mono-cgroup-minmemsz-fix.txt

    @nealef given that this is originally your implementation, could you move that forward as PRs in all affected branches as well? Thanks!

  12. nealef commented on Oct 28, 2022

    @nealef
  13. janani66 commented on Nov 1, 2022

    @janani66
    Contributor

    I have been able to verify the fix in the runtime repo

    [root@kop5 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=200M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    157286400
    [root@kop5 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=100M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    78643200
    [root@kop5 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=250M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    196608000
    [root@kop5 cgroup-limit]# systemd-run -q --scope -p CPUQuota=100% -p MemoryLimit=300M bin/Debug/net7.0/cgroup-limit
    Limits:
    1
    235929600

  14. omajid commented on Dec 20, 2022

    @omajid
    MemberAuthor

    Fixed with #225 and #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions