RFR: JDK-8324598: use mem_unit when working with sysinfo memory and swap related information
David Holmes
dholmes at openjdk.org
Thu Jan 25 05:45:27 UTC 2024
On Wed, 24 Jan 2024 10:07:17 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
> According to the sysinfo manpage ( https://man7.org/linux/man-pages/man2/sysinfo.2.html ) the memory and swap related entries in the struct sysinfo are given as multiples of mem_unit bytes.
> "In the above structure, sizes of the memory and swap fields are given as multiples of mem_unit bytes."
>
> This is considered in most parts of the OpenJDK codebase when sysinfo is used but not all; should be added where it is missing.
Looks fine.
Minor nit with lack of parentheses.
Thanks
src/hotspot/os/linux/os_linux.cpp line 420:
> 418: struct sysinfo si;
> 419: sysinfo(&si);
> 420: return (julong)si.totalswap * si.mem_unit;
Suggestion: `(julong)(si.totalswap * si.mem_unit);
src/java.base/linux/native/libjava/CgroupMetrics.c line 57:
> 55: return 0; // syinfo failed, treat as no swap
> 56: }
> 57: return (jlong)si.totalswap * si.mem_unit;
Suggestion: `(julong)(si.totalswap * si.mem_unit);
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17550#pullrequestreview-1842877781
PR Review Comment: https://git.openjdk.org/jdk/pull/17550#discussion_r1465868336
PR Review Comment: https://git.openjdk.org/jdk/pull/17550#discussion_r1465868493
More information about the core-libs-dev
mailing list