Re: RFR: JDK-8324287: Record total and free swap space in JFR [v5]
On Mon, 29 Jan 2024 15:16:48 GMT, Matthias Baesken <mbaesken@openjdk.org> wrote:
Total and free swap space should be recorded in JFR, because it is important to know e.g. in case of memory shortages.
Currently we only have a container related event (ContainerMemoryUsage) that provides some info but no general event. PhysicalMemory could be enhanced or a new event added.
There is already some coding (see Java_com_sun_management_internal_OperatingSystemImpl_getTotalSwapSpaceSize0 and Java_com_sun_management_internal_OperatingSystemImpl_getFreeSwapSpaceSize0) for the swap space info retrieval.
Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
Linux: container support in os::total_swap_space
src/hotspot/os/linux/os_linux.cpp line 294:
292: jlong os::total_swap_space() { 293: if (OSContainer::is_containerized()) { 294: return (jlong)(OSContainer::memory_and_swap_limit_in_bytes() - OSContainer::memory_limit_in_bytes());
Shouldn't we check if `OSContainer::memory_limit_in_bytes() > 0` here first? src/hotspot/os/linux/os_linux.cpp line 313:
311: } 312: return (jlong)(si.freeswap * si.mem_unit); 313: }
In a containerized environment with some memory limit this could potentially return a large value for `free_swap_space()`, and a small(er) value for `total_swap_space()`. i.e. `total_swap_space() < free_swap_space()`. Please return `-1` if the containerized value is not supported. Better yet, push the implementation to `Linux::free_swap_space()` and `Linux::total_swap_space()` which always returns host swap values and do the (container) wrappers here in `os::free_swap_space()` and `os::total_swap_space()`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17581#discussion_r1469776435 PR Review Comment: https://git.openjdk.org/jdk/pull/17581#discussion_r1469773728
On Mon, 29 Jan 2024 15:32:47 GMT, Severin Gehwolf <sgehwolf@openjdk.org> wrote:
In a containerized environment with some memory limit this could potentially return a large value for `free_swap_space()`, and a small(er) value for `total_swap_space()`. i.e. `total_swap_space() < free_swap_space()`.
Yes this is what we see in our tests last night (after my change).
Please return `-1` if the containerized value is not supported.
okay I can do this. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17581#discussion_r1471322500
participants (2)
-
Matthias Baesken
-
Severin Gehwolf