Skip to content

Commit

Permalink
8324598: use mem_unit when working with sysinfo memory and swap relat…
Browse files Browse the repository at this point in the history
…ed information

Backport-of: 7a798d3cebea0915f8a73af57333b3488c2091af
  • Loading branch information
MBaesken committed Feb 8, 2024
1 parent cfceb11 commit d08f24a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pid_t os::Linux::gettid() {
julong os::Linux::host_swap() {
struct sysinfo si;
sysinfo(&si);
return (julong)si.totalswap;
return (julong)(si.totalswap * si.mem_unit);
}

// Most versions of linux have a bug where the number of processors are
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/linux/native/libjava/CgroupMetrics.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Red Hat, Inc.
* Copyright (c) 2020, 2024, Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -54,5 +54,5 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0
if (retval < 0) {
return 0; // syinfo failed, treat as no swap
}
return (jlong)si.totalswap;
return (jlong)(si.totalswap * si.mem_unit);
}

1 comment on commit d08f24a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.