From 0a6eb64529321c86435efdccd267763526314d2d Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Thu, 8 May 2025 13:18:02 +0000 Subject: [PATCH 1/3] 8351359: OperatingSystemMXBean: values from getCpuLoad and getProcessCpuLoad are stale after 24.8 days (Windows) Reviewed-by: amenkov, sspitsyn --- jdk/src/windows/native/sun/management/OperatingSystemImpl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c index 04dbf8497c8..0fbb900a462 100644 --- a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c +++ b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c @@ -215,7 +215,7 @@ static PdhLookupPerfNameByIndexFunc PdhLookupPerfNameByIndex_i; */ typedef struct { HQUERY query; - uint64_t lastUpdate; // Last time query was updated (ticks) + uint64_t lastUpdate; // Last time query was updated (millis) } UpdateQueryS, *UpdateQueryP; // Min time between query updates (ticks) @@ -993,7 +993,7 @@ bindPdhFunctionPointers(HMODULE h) { */ static int getPerformanceData(UpdateQueryP query, HCOUNTER c, PDH_FMT_COUNTERVALUE* value, DWORD format) { - clock_t now = clock(); + uint64_t now = GetTickCount64(); /* * Need to limit how often we update the query From e2bff15e4698455e537ccfc5078d26dba4fd99d7 Mon Sep 17 00:00:00 2001 From: Anton Voznia Date: Mon, 22 Sep 2025 16:01:07 +0200 Subject: [PATCH 2/3] Fix comment. --- jdk/src/windows/native/sun/management/OperatingSystemImpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c index 0fbb900a462..d2e3873b3c8 100644 --- a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c +++ b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c @@ -218,7 +218,7 @@ typedef struct { uint64_t lastUpdate; // Last time query was updated (millis) } UpdateQueryS, *UpdateQueryP; -// Min time between query updates (ticks) +// Min time between query updates (millis) static const int MIN_UPDATE_INTERVAL = 500; /* From 15ed07b3f073b4df1566c63c4e441aabc52f91c9 Mon Sep 17 00:00:00 2001 From: Anton Voznia Date: Tue, 23 Sep 2025 17:59:09 +0200 Subject: [PATCH 3/3] Fix copyright year. --- jdk/src/windows/native/sun/management/OperatingSystemImpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c index d2e3873b3c8..898b7d434b9 100644 --- a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c +++ b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it