RFR: 8356868: Not all cgroup parameters are made available

Severin Gehwolf sgehwolf at openjdk.org
Tue Jun 3 11:54:52 UTC 2025


On Thu, 22 May 2025 09:06:15 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:

> Hi everyone,
> 
> This PR improves cgroup support by exposing additional parameters that are currently not available. These parameters would enable more advanced features that rely on CPU and memory usage data.
> 
> The new parameters are:
> 
> - CPU usage: `cpuacct.usage` (cgroup v1) and `cpu.stat` (cgroup v2), which allow precise tracking of consumed CPU time.
> 
> - Peak memory usage: `memory.peak` (cgroup v2). While the cgroup v1 equivalent (`memory.max_usage_in_bytes`) was already available, cgroup v2 previously returned `OSCONTAINER_ERROR` — this has now been fixed.
> 
> - Memory throttle limit: `memory.high` (cgroup v2). There is no direct equivalent in cgroup v1, but since most systems use cgroup v2, exposing this parameter enables finer-grained memory control for those systems.
> 
> Testing:
> - All container tests under `/test/hotspot/jtreg/containers/`
> - Manually inspected the new parameters in both cgroup v1 and v2 container environments with the relevant settings applied.

This looks fine to me. One suggestion as I think the cpu usage might be 0 and greater.

src/hotspot/os/linux/os_linux.cpp line 2494:

> 2492:   st->print("cpu_usage_in_micros: ");
> 2493:   if (j > 0) {
> 2494:     st->print_cr(JLONG_FORMAT, j);

Suggestion:

  if (j >= 0) {
    st->print_cr(JLONG_FORMAT, j);

-------------

Marked as reviewed by sgehwolf (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25388#pullrequestreview-2891786092
PR Review Comment: https://git.openjdk.org/jdk/pull/25388#discussion_r2123443807


More information about the hotspot-runtime-dev mailing list