RFR: JDK-8284758: [linux] improve print_container_info [v2]
Severin Gehwolf
sgehwolf at openjdk.java.net
Wed Apr 13 16:31:17 UTC 2022
On Wed, 13 Apr 2022 16:07:35 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/os/linux/os_linux.cpp line 2191:
>>
>>> 2189: st->print("%s: ", metrics);
>>> 2190: if (j > 0) {
>>> 2191: st->print_cr(UINT64_FORMAT " k", uint64_t(j) / 1024);
>>
>> Shouldn't this check whether or not `j >= 1024` before doing the division? I'm thinking:
>>
>> if (j > 0) {
>> if (j >= 1024) {
>> st->print_cr(UINT64_FORMAT " k", uint64_t(j) / 1024);
>> } else {
>> st->print_cr(UINT64_FORMAT, uint64_t(j));
>> }
>
> Aren't these sizes page-aligned anyway?
I don't see why. For example value `OSContainer::memory_limit_in_bytes()` comes from the cgroup interface files. Basically whatever the user specifies via the container engine's `--memory` switch. For example `--memory 123412332` is fine.
$ sudo podman run --rm -ti --memory 128974848 --memory-swap 128974848 -v $(pwd)/build/linux-x86_64-server-release/images/jdk:/opt/jdk:z fedora:35 /opt/jdk/bin/java -Xlog:os+container=trace -version 2>&1 | grep -C2 memory.limit_in_bytes
[0.001s][trace][os,container] Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes
[0.001s][trace][os,container] Memory Limit is: 128974848
[0.001s][info ][os,container] Memory Limit is: 128974848
-------------
PR: https://git.openjdk.java.net/jdk/pull/8217
More information about the hotspot-runtime-dev
mailing list