RFR: 8371408: [Linux] VM.info output for container information is confusing
Casper Norrbin
cnorrbin at openjdk.org
Thu Dec 11 12:08:36 UTC 2025
Hi everyone,
The current `VM.info` printout for container limits can be made clearer and easier to read. The original formatting was designed around cgroup v1, directly mirroring its file names and conventions. Since then, most environments have transitioned to cgroup v2. While the output is still correct, its readability suffers. For example, memory metrics have a `_in_bytes` suffix, but the printed values are actually in kilobytes with a `k` suffix.
This PR removes the `_in_*` suffixes from metric names and adds appropriate units (e.g. `kB`, `us`) directly to the values. At the same time, I have also improved the formatting of the output so that all values and units are column-aligned, similar to the `/proc/meminfo` section immediately above in the `VM.info` printout.
Here is the container printout before:
container (cgroup) information:
container_type: cgroupv1
cpu_cpuset_cpus: 0-15
cpu_memory_nodes: 0-1
active_processor_count: 16, but overridden by -XX:ActiveProcessorCount 8
cpu_quota: 1600000
cpu_period: 100000
cpu_shares: no shares
cpu_usage_in_micros: 2648091
memory_limit_in_bytes: 4194304 k
memory_and_swap_limit_in_bytes: 8388608 k
memory_soft_limit_in_bytes: unlimited
memory_throttle_limit_in_bytes: unavailable
memory_usage_in_bytes: 61116 k
memory_max_usage_in_bytes: 61116 k
rss_usage_in_bytes: 56332 k
cache_usage_in_bytes: 1880 k
kernel_memory_limit_in_bytes: unlimited
kernel_memory_usage_in_bytes: 1584 k
kernel_memory_max_usage_in_bytes: 1644 k
maximum number of tasks: unlimited
current number of tasks: 17
And here it is after:
container (cgroup) information:
container_type: cgroupv1
cpu_cpuset_cpus: 0-15
cpu_memory_nodes: 0-1
active_processor_count: 8 (from -XX:ActiveProcessorCount)
cpu_quota: 1600000
cpu_period: 100000
cpu_shares: no shares
cpu_usage: 2648091 us
memory_limit: 4194304 kB
memory_and_swap_limit: 8388608 kB
memory_soft_limit: unlimited
memory_throttle_limit: unavailable
memory_usage: 61116 kB
memory_max_usage: 61116 kB
rss_usage: 56332 kB
cache_usage: 1880 kB
kernel_memory_limit: unlimited
kernel_memory_usage: 1584 kB
kernel_memory_max_usage: 1644 kB
maximum number of tasks: unlimited
current number of tasks: 17
To accomplish this, I have added a new `OSContainer::print_container_metric()` function that does the prettified printing. This function is templated to accept various value types and relies on a helper struct to select the correct format string at compile time. This is necessary since dynamic format strings are not allowed (`-Wformat-nonliteral`). As a consequence, we have to explicitly instantiate the function for each templated type.
The updated formatting required changes to some tests, as they previously matched the old strings exactly. I have updated these tests to use more robust regex checks.
Testing:
- Oracle tiers 1-5
- Local container tests on cgroup v1 and v2 on both Podman and Docker
-------------
Commit messages:
- improved container limit printing
Changes: https://git.openjdk.org/jdk/pull/28766/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28766&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8371408
Stats: 109 lines in 10 files changed: 32 ins; 20 del; 57 mod
Patch: https://git.openjdk.org/jdk/pull/28766.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28766/head:pull/28766
PR: https://git.openjdk.org/jdk/pull/28766
More information about the hotspot-runtime-dev
mailing list