8333522: JFR SwapSpace event might read wrong free swap space size

Reviewed-by: sgehwolf, lucy
This commit is contained in:
Matthias Baesken 2024-06-10 08:14:23 +00:00
parent a941397327
commit de55db2352

View File

@ -314,7 +314,10 @@ static jlong host_free_swap() {
}
jlong os::free_swap_space() {
jlong host_free_swap_val = host_free_swap();
// os::total_swap_space() might return the containerized limit which might be
// less than host_free_swap(). The upper bound of free swap needs to be the lower of the two.
jlong host_free_swap_val = MIN2(os::total_swap_space(), host_free_swap());
assert(host_free_swap_val >= 0, "sysinfo failed?");
if (OSContainer::is_containerized()) {
jlong mem_swap_limit = OSContainer::memory_and_swap_limit_in_bytes();
jlong mem_limit = OSContainer::memory_limit_in_bytes();