RFR: 8371408: [Linux] VM.info output for container information is confusing [v2]
Casper Norrbin
cnorrbin at openjdk.org
Fri Dec 12 11:59:33 UTC 2025
On Fri, 12 Dec 2025 01:38:02 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Casper Norrbin has updated the pull request incrementally with one additional commit since the last revision:
>>
>> cross-compile fix
>
> src/hotspot/os/linux/osContainer_linux.cpp line 308:
>
>> 306: os::snprintf_checked(value_str, longest_value, metric_fmt<T>::fmt, value);
>> 307: st->print("%s: %*s", metrics, max_length - static_cast<int>(strlen(metrics)) - 2, value_str); // -2 for the ": "
>> 308: st->print_cr(unit[0] != '\0' ? " %s" : "", unit);
>
> Might a format checker complain about passing `unit` in the case there is no actual format specifier provided?
While this is explicitly allowed in the C standard, it could maybe cause some checker to complain. I didn't have any issues, but I went ahead and split this into two prints to be safe.
> src/hotspot/os/linux/osContainer_linux.cpp line 315:
>
>> 313: if (res.value() != value_unlimited) {
>> 314: if (res.value() >= 1024) {
>> 315: print_container_metric(st, metrics, res.value() / K, "kB");
>
> Pre-existing, but does this assume the value will always be a multiple of K?
We either assume that it's a multiple of K, or we accept some loss in accuracy. The memory values where this function is used are often large and are specified in MB/GB, so will be evenly divisible. One could set a weird manual value, and in that case we would lose some accuracy.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28766#discussion_r2613958672
PR Review Comment: https://git.openjdk.org/jdk/pull/28766#discussion_r2613953824
More information about the hotspot-runtime-dev
mailing list