RFR: 8321931: memory_swap_current_in_bytes reports 0 as "unlimited" [v6]

Gerard Ziemski gziemski at openjdk.org
Thu Jan 25 16:42:51 UTC 2024


On Thu, 25 Jan 2024 16:27:04 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:

>> We make a distinction between 0 for a limit vs non-limit cgroup values.
>> 
>> For all values (limit or non-limit), 0 simply means 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".
>
> Gerard Ziemski has updated the pull request incrementally with five additional commits since the last revision:
> 
>  - whitespace
>  - remove the check, we have a dedicated test for it
>  - fix comment
>  - relax syntax check for 0
>  - add test provided by jerboaa

I have added your test with one change.

Instead of checking for strict syntax:

`out.shouldContain("memory_swap_current_in_bytes: 0"))`

we do:


            for (String s : str.split(System.lineSeparator())) {
                if (s.contains("memory_swap_current_in_bytes")) {
                    s.shouldContain("0");
                    s.shouldNotContain("unlimited");
                }
            }


I did this in anticipation of [JDK-8321932](https://bugs.openjdk.org/browse/JDK-8321932) which will change the layout.

> > > I feel like I don't have enough container knowledge to write such a test, without investing more time learning the basics. Would you kindly help and write the test you want please? At least the part that sets up the environment and starts the test (on Linux only?) with swap==0 ?
> > 
> > 
> > Sure. Here you go: [gerard-ziemski#1](https://github.com/gerard-ziemski/jdk/pull/1)
> 
> Thank you very much!
> 
> I will incorporate it into this fix shortly...

Ready for a re-review.

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

PR Comment: https://git.openjdk.org/jdk/pull/17314#issuecomment-1910577611


More information about the hotspot-runtime-dev mailing list