RFR: 8321931: memory_swap_current_in_bytes reports 0 as "unlimited"

Thomas Stuefe stuefe at openjdk.org
Tue Jan 16 18:16:20 UTC 2024


On Mon, 8 Jan 2024 21:28:46 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:

> We make a distinction between 0 for a limit vs non-limit cgroup values.
> 
> For a limit-type value, 0 means `unlimited`. For all the others 0 means simply 0.
> 
> Output before from `jcmd PID VM.info`:
> 
> 
> container (cgroup) information:
> container_type: cgroupv2
> cpu_cpuset_cpus: not supported
> cpu_memory_nodes: not supported
> active_processor_count: 8
> cpu_quota: not supported
> cpu_period: not supported
> cpu_shares: not supported
> memory_limit_in_bytes: unlimited
> memory_and_swap_limit_in_bytes: unlimited
> memory_soft_limit_in_bytes: unlimited
> memory_usage_in_bytes: 11129120 k
> memory_max_usage_in_bytes: not supported
> memory_swap_current_in_bytes: unlimited
> memory_swap_max_limit_in_bytes: unlimited
> maximum number of tasks: 18963
> current number of tasks: 33
> 
> 
> Output now from `jcmd PID VM.info`:
> 
> 
> container (cgroup) information:
> container_type: cgroupv2
> cpu_cpuset_cpus: not supported
> cpu_memory_nodes: not supported
> active_processor_count: 8
> cpu_quota: not supported
> cpu_period: not supported
> cpu_shares: not supported
> memory_limit_in_bytes: unlimited
> memory_and_swap_limit_in_bytes: unlimited
> memory_soft_limit_in_bytes: unlimited
> memory_usage_in_bytes: 4962584 k
> memory_max_usage_in_bytes: not supported
> memory_swap_current_in_bytes: 0
> memory_swap_max_limit_in_bytes: unlimited
> maximum number of tasks: 18963
> current number of tasks: 33
> 
> In this example `memory_swap_current_in_bytes` should be printed as equal to 0, not "unlimited".

Are we sure 0 means unlimited? I looked at https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
and did not find any remarks.

https://unix.stackexchange.com/questions/420906/what-is-the-value-for-the-cgroups-limit-in-bytes-if-the-memory-is-not-restricte seems to indicate the value is some very high number. Or is this handled by the JVMs cgroup layer?

src/hotspot/os/linux/osContainer_linux.cpp line 142:

> 140: void OSContainer::print_container_helper(outputStream* st, jlong j, const char* metrics, boolean limit) {
> 141:   st->print("%s: ", metrics);
> 142:   if ((j > 0) || ((j == 0) && (limit == false))) {

Clearer would be a reversal like this:

if (j == 0 && limit) {
  "unlimited"
} else {
  print
}

src/hotspot/os/linux/osContainer_linux.hpp line 48:

> 46:   static void init();
> 47:   static void print_version_specific_info(outputStream* st);
> 48:   static void print_container_helper(outputStream* st, jlong j, const char* metrics, boolean limit = false);

Can we name this parameter better, or add a comment at least?

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

PR Review: https://git.openjdk.org/jdk/pull/17314#pullrequestreview-1824491821
PR Review Comment: https://git.openjdk.org/jdk/pull/17314#discussion_r1453793277
PR Review Comment: https://git.openjdk.org/jdk/pull/17314#discussion_r1453800929


More information about the hotspot-runtime-dev mailing list