8324598: use mem_unit when working with sysinfo memory and swap related information

Reviewed-by: dholmes, mdoerr
This commit is contained in:
Matthias Baesken 2024-01-25 10:36:00 +00:00
parent 6d36eb78ad
commit 7a798d3ceb
2 changed files with 3 additions and 3 deletions

View file

@ -417,7 +417,7 @@ pid_t os::Linux::gettid() {
julong os::Linux::host_swap() { julong os::Linux::host_swap() {
struct sysinfo si; struct sysinfo si;
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 // Most versions of linux have a bug where the number of processors are

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,5 +54,5 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0
if (retval < 0) { if (retval < 0) {
return 0; // syinfo failed, treat as no swap return 0; // syinfo failed, treat as no swap
} }
return (jlong)si.totalswap; return (jlong)(si.totalswap * si.mem_unit);
} }