Skip to content

Commit d3d67ec

Browse files
committed
8385892: TestResidentSetSizeEvent fails with RuntimeException: Should be non-zero: expected 0 > 0
Reviewed-by: mgronlun, jbechberger
1 parent c01b025 commit d3d67ec

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

src/hotspot/os/linux/os_linux.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,14 +2860,39 @@ void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
28602860

28612861
#if INCLUDE_JFR
28622862

2863+
// hwm (high water mark) in K for the VM RSS
2864+
static long jfr_rss_hwm_k = -1;
2865+
2866+
static void send_resident_set_size_event(ssize_t size, ssize_t peak) {
2867+
EventResidentSetSize event;
2868+
event.set_size(size * K);
2869+
event.set_peak(peak * K);
2870+
event.commit();
2871+
}
2872+
28632873
void os::jfr_report_memory_info() {
2874+
os::Linux::accurate_meminfo_t accurate_info;
2875+
if (os::Linux::query_accurate_process_memory_info(&accurate_info) && accurate_info.rss != -1) {
2876+
// unfortunately the smaps_rollup/accurate_info contains no hwm (high water mark) for RSS
2877+
struct rusage ru;
2878+
if (getrusage(RUSAGE_SELF, &ru) == 0) {
2879+
if (ru.ru_maxrss > jfr_rss_hwm_k) {
2880+
jfr_rss_hwm_k = ru.ru_maxrss;
2881+
}
2882+
}
2883+
2884+
// do not allow larger current RSS than hwm
2885+
if (accurate_info.rss > jfr_rss_hwm_k) {
2886+
jfr_rss_hwm_k = accurate_info.rss;
2887+
}
2888+
2889+
send_resident_set_size_event(accurate_info.rss, jfr_rss_hwm_k);
2890+
return;
2891+
}
2892+
28642893
os::Linux::meminfo_t info;
28652894
if (os::Linux::query_process_memory_info(&info)) {
2866-
// Send the RSS JFR event
2867-
EventResidentSetSize event;
2868-
event.set_size(info.vmrss * K);
2869-
event.set_peak(info.vmhwm * K);
2870-
event.commit();
2895+
send_resident_set_size_event(info.vmrss, info.vmhwm);
28712896
} else {
28722897
// Log a warning
28732898
static bool first_warning = true;

0 commit comments

Comments
 (0)