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

[linux] Remove deprecated Metrics api (kernel memory limit)

XMLWordPrintable

    • b22
    • generic
    • linux
    • Verified

        In the - cgroup v1 specific - Metrics api there is reporting of the set kernel memory limit:

            public long getKernelMemoryLimit() {
                return CgroupV1SubsystemController.longValOrUnlimited(getLongValue(memory, "memory.kmem.limit_in_bytes"));
            }

            public long getTcpMemoryLimit() {
                return CgroupV1SubsystemController.longValOrUnlimited(getLongValue(memory, "memory.kmem.tcp.limit_in_bytes"));
            }

        The cgroup v1 API has been deprecated in the Linux kernel and there are container runtime implementations released which already ignore setting a kernel memory limit when being asked to do so via --kernel-memory switch.

        Note that it's not supported at all on cgroups v2.

        Therefore, this code should get removed as it'll stop doing anything anyway (other than reporting unlimited in any case).

        Example docker-only reproducer:
        # docker run --kernel-memory=200m --rm -ti fedora:34 cat sys/fs/cgroup/memory/memory.kmem.limit_in_bytes
        WARNING: Specifying a kernel memory limit is deprecated and will be removed in a future release.
        9223372036854771712

        References:

        Kernel commit adding the deprecation:
        https://github.com/torvalds/linux/commit/0158115f702b

        runc container runtime PR which ignores any setting of --kernel-memory:
        https://github.com/opencontainers/runc/pull/2840

        podman PR which hides '--kernel-memory' as an option for 'podman run':
        https://github.com/containers/podman/pull/12048

        OCI runtime spec update discouraging using/implementing it in container runtimes:
        https://github.com/opencontainers/runtime-spec/pull/1093

              sgehwolf Severin Gehwolf
              sgehwolf Severin Gehwolf
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: