From 66f540698ef01e55356b2e666c3d61b4a740c244 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Mon, 28 Sep 2026 07:54:51 +0200 Subject: [PATCH 01/11] Improve vitals and related stuff. --- src/hotspot/os/linux/os_linux.cpp | 85 +++++++++++++++++-- src/hotspot/os/linux/os_linux.hpp | 4 + src/hotspot/os/linux/vitals_linux.cpp | 4 - .../os/linux/vitals_linux_himemreport.cpp | 2 +- .../os/linux/vitals_linux_himemreport.hpp | 2 +- .../os/linux/vitals_linux_oswrapper.cpp | 43 +--------- .../os/linux/vitals_linux_oswrapper.hpp | 1 - src/hotspot/share/vitals/vitals.cpp | 4 +- .../jtreg/runtime/Vitals/TestHiMemReport.java | 6 +- .../jtreg/runtime/Vitals/VitalsUtils.java | 2 +- .../Vitals/VitalsValuesSanityCheck.java | 11 +-- 11 files changed, 95 insertions(+), 69 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index f84c576f0c22..75d1737769d8 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -61,6 +61,7 @@ #include "runtime/threads.hpp" #include "runtime/threadSMR.hpp" #include "runtime/timer.hpp" +#include "runtime/timerTrace.hpp" #include "runtime/vm_version.hpp" #include "semaphore_posix.hpp" #include "services/runtimeService.hpp" @@ -1154,13 +1155,31 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread \"%s\" - pthread_create failed (%s) for attributes: %s.", thread->name(), os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); - // Log some OS information which might explain why creating the thread failed. - log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); - LogStream st(Log(os, thread)::info()); - os::Posix::print_rlimit_info(&st); - os::print_memory_info(&st); - os::Linux::print_proc_sys_info(&st); - os::Linux::print_container_info(&st); + // Log some OS information which might explain why creating the thread failed. Since this + // is a lot of output we only use warning level first and then turn it down to Info. + static bool is_first = true; + + if (is_first || log_is_enabled(Info, os, thread)) { + uint64_t procs, threads; + + LogStream stw(Log(os, thread)::warning()); + LogStream sti(Log(os, thread)::info()); + LogStream* st = is_first ? &stw : &sti; + + st->print_cr("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + + if (os::Linux::get_total_procs_and_threads(&procs, &threads)) { + st->print_cr("Number of processes on the system: " UINT64_FORMAT, procs); + st->print_cr("Number of threads on the system: " UINT64_FORMAT, threads); + } + + os::Posix::print_rlimit_info(st); + os::print_memory_info(st); + os::Linux::print_proc_sys_info(st); + os::Linux::print_container_info(st); + + is_first = false; + } } pthread_attr_destroy(&attr); @@ -2448,6 +2467,58 @@ bool os::Linux::query_accurate_process_memory_info(os::Linux::accurate_meminfo_t return true; } +// Helper function, returns true if string is a numerical id +static bool is_numerical_id(const char* s) { + const char* p = s; + while(*p >= '0' && *p <= '9') { + p ++; + } + return *p == '\0' ? true : false; +} + +bool os::Linux::get_total_procs_and_threads(uint64_t* procs, uint64_t* threads) { + TraceTime timer("Iterating all processes", TRACETIME_LOG(Trace, os, timer)); + DIR* d = ::opendir("/proc"); + if (d != nullptr) { + uint64_t procs_count = 0; + uint64_t threads_count = 0; + struct dirent* en = nullptr; + do { + en = ::readdir(d); + if (en != nullptr) { + if (is_numerical_id(en->d_name)) { + procs_count++; + if (threads == nullptr) { + continue; + } + char tmp[128]; + jio_snprintf(tmp, sizeof(tmp), "/proc/%s/stat", en->d_name); + FILE *fp = os::fopen(tmp, "r"); + if (fp != nullptr) { + // See man proc(5) + // (20) num_threads %ld + long num_threads = 0; + ::fscanf(fp, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld", &num_threads); + threads_count += num_threads; + ::fclose(fp); + } + } + } + } while(en != nullptr); + ::closedir(d); + if (procs != nullptr) { + *procs = procs_count; + } + if (threads != nullptr) { + *threads = threads_count; + } + + return true; + } + + return false; +} + #ifdef __GLIBC__ // For Glibc, print a one-liner with the malloc tunables. // Most important and popular is MALLOC_ARENA_MAX, but we are diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index a01e0f6dfd39..5e2ce3c4b8d5 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -187,6 +187,10 @@ class os::Linux { // fields will contain -1. static bool query_accurate_process_memory_info(accurate_meminfo_t* info); + // Gets the total number of processes and threads on the system. If parameter is nullptr + // the value isn't determined. This is useful since the thread count is somewhat expensivce. + static bool get_total_procs_and_threads(uint64_t* procs, uint64_t* threads); + // Tells if the user asked for transparent huge pages. static bool _thp_requested; diff --git a/src/hotspot/os/linux/vitals_linux.cpp b/src/hotspot/os/linux/vitals_linux.cpp index ad1976f819f0..72c5e34c19fe 100644 --- a/src/hotspot/os/linux/vitals_linux.cpp +++ b/src/hotspot/os/linux/vitals_linux.cpp @@ -101,7 +101,6 @@ static Column* g_col_system_pages_swapped_in = nullptr; static Column* g_col_system_pages_swapped_out = nullptr; static Column* g_col_system_num_procs = nullptr; -static Column* g_col_system_num_threads = nullptr; static Column* g_col_system_num_procs_running = nullptr; static Column* g_col_system_num_procs_blocked = nullptr; @@ -173,8 +172,6 @@ bool platform_columns_initialize() { g_col_system_num_procs = define_column(system_cat, nullptr, "p", "Number of processes", true); - g_col_system_num_threads = - define_column(system_cat, nullptr, "t", "Number of threads", true); g_col_system_num_procs_running = define_column(system_cat, nullptr, "tr", "Number of threads running", true); @@ -302,7 +299,6 @@ void sample_platform_values(Sample* sample, Sample* long_term_sample) { } set_value_in_sample(g_col_system_num_procs, sample, OSWrapper::syst_p()); - set_value_in_sample(g_col_system_num_threads, sample, OSWrapper::syst_t()); set_value_in_sample(g_col_process_virt, sample, OSWrapper::proc_virt()); set_value_in_sample(g_col_process_swapped_out, sample, OSWrapper::proc_swdo()); diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.cpp b/src/hotspot/os/linux/vitals_linux_himemreport.cpp index 86e68fce0b32..94dfacffa07d 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.cpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025 SAP SE. All rights reserved. + * Copyright (c) 2022, 2026 SAP SE. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.hpp b/src/hotspot/os/linux/vitals_linux_himemreport.hpp index cc173b1b853b..318ca594dda7 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.hpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 SAP SE. All rights reserved. + * Copyright (c) 2022, 2026 SAP SE. All rights reserved. * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp index 77cb8ec6a151..7e824d49e4d2 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp @@ -27,7 +27,6 @@ #include "logging/log.hpp" #include "osContainer_linux.hpp" #include "runtime/os.hpp" -#include "runtime/timerTrace.hpp" #include "utilities/globalDefinitions.hpp" #include "vitals/vitals_internals.hpp" #include "vitals_linux_oswrapper.hpp" @@ -221,15 +220,6 @@ static void mallinfo_init() { #endif // __GLIBC__ -// Helper function, returns true if string is a numerical id -static bool is_numerical_id(const char* s) { - const char* p = s; - while(*p >= '0' && *p <= '9') { - p ++; - } - return *p == '\0' ? true : false; -} - /////////////// cgroup stuff // We use part of the hotspot cgroup wrapper, but not all of it. // The reason: @@ -493,38 +483,7 @@ ALL_VALUES_DO(RESETVAL) } } - // Number of processes: iterate over /proc/ and count. - // Number of threads: read "num_threads" from /proc//stat - { - TraceTime timer("Iterating all processes", TRACETIME_LOG(Debug, vitals, os)); - DIR* d = ::opendir("/proc"); - if (d != nullptr) { - value_t v_p = 0; - value_t v_t = 0; - struct dirent* en = nullptr; - do { - en = ::readdir(d); - if (en != nullptr) { - if (is_numerical_id(en->d_name)) { - v_p ++; - char tmp[128]; - jio_snprintf(tmp, sizeof(tmp), "/proc/%s/stat", en->d_name); - if (bf.read(tmp)) { - const char* text = bf.text(); - // See man proc(5) - // (20) num_threads %ld - long num_threads = 0; - ::sscanf(text, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld", &num_threads); - v_t += num_threads; - } - } - } - } while(en != nullptr); - ::closedir(d); - _syst_p = v_p; - _syst_t = v_t; - } - } + os::Linux::get_total_procs_and_threads(&_syst_p, nullptr); if (bf.read("/proc/self/io")) { _proc_io_rd = bf.parsed_prefixed_value("rchar:"); diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.hpp b/src/hotspot/os/linux/vitals_linux_oswrapper.hpp index 21ae709c2236..74e2e057176c 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.hpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.hpp @@ -45,7 +45,6 @@ class OSWrapper { f(syst_si) \ f(syst_so) \ f(syst_p) \ - f(syst_t) \ f(syst_tr) \ f(syst_tb) \ f(syst_load_average) \ diff --git a/src/hotspot/share/vitals/vitals.cpp b/src/hotspot/share/vitals/vitals.cpp index d8847583ee08..7753fb6aedcc 100644 --- a/src/hotspot/share/vitals/vitals.cpp +++ b/src/hotspot/share/vitals/vitals.cpp @@ -40,6 +40,7 @@ #include "runtime/os.hpp" #include "runtime/thread.hpp" #include "runtime/threads.hpp" +#include "runtime/timerTrace.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -970,6 +971,7 @@ static SampleTables* g_all_tables = nullptr; // Samples all values, but leaves timestamp unchanged static void sample_values(Sample* sample, Sample* long_term_sample, bool avoid_locking) { + TraceTime timer("Sampling the values", TRACETIME_LOG(Trace, vitals, timer)); time_t t; ::time(&t); sample->set_timestamp(t); @@ -1034,8 +1036,8 @@ class SamplerThread: public NamedThread { virtual void run() { record_stack_base_and_size(); for (;;) { - take_sample(g_all_tables->next_sample_is_for_long_term()); os::naked_sleep(get_sample_interval_ms()); + take_sample(g_all_tables->next_sample_is_for_long_term()); if (_stop) { break; } diff --git a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java index c770e0ea0665..cf78f1660d97 100644 --- a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java +++ b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 SAP SE. All rights reserved. + * Copyright (c) 2021, 2026 SAP SE. 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 @@ -159,7 +159,7 @@ static void testDumpWithExecToReportDir() throws Exception { "-XX:NativeMemoryTracking=summary", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), - "sleep", "12" // num seconds to sleep to give the reporter thread time to generate output + "sleep", "30" // num seconds to sleep to give the reporter thread time to generate output ); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -266,7 +266,7 @@ static void testDumpWithExecToStderr() throws Exception { "-XX:NativeMemoryTracking=summary", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), - "sleep", "8" // num seconds to sleep to give the reporter thread time to generate output + "sleep", "20" // num seconds to sleep to give the reporter thread time to generate output ); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java b/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java index 620a3e41620c..096590844d4d 100644 --- a/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java +++ b/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java @@ -74,7 +74,7 @@ static int matchPatterns(String[] lines, int startAtLine, String[] regexes) { } if (nextToMatch < regexes.length) { throw new RuntimeException("Not all matches found. First missing pattern " + nextToMatch + ":" + regexes[nextToMatch] + - "\nOutput: " + String.join("\n", lines)); + "\nOutput: " /* + String.join("\n", lines)*/); } return nLine; } diff --git a/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java b/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java index 33543144ecc8..912dfd9f185d 100644 --- a/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java +++ b/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, SAP SE. All rights reserved. + * Copyright (c) 2022, 2026 SAP SE. 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 @@ -128,9 +128,9 @@ private static long findHighestValueForColumn(CSVParser.CSV csv, String colname) */ private static void checkValueIsBetween(long value, String colname, long min, long max) { if (value < min) { - throw new RuntimeException(colname + " seems too low (expected at least " + min + ")"); + throw new RuntimeException(colname + "(" + value + ") seems too low (expected at least " + min + ")"); } else if (value >= max) { - throw new RuntimeException(colname + " seems too high (expected at most " + max + ")"); + throw new RuntimeException(colname + "(" + value + ") seems too high (expected at most " + max + ")"); } } @@ -269,11 +269,6 @@ public void run(CommandExecutor executor) { long min_expected_kernel_threads = min_expected_java_threads; long max_expected_kernel_threads = 1000000000; // same here - long syst_t = checkValueIsBetween(csv, "syst-t", min_expected_kernel_threads, max_expected_kernel_threads); - - // threads running, blocked on disk IO (cannot be larger than number of kernel threads) - checkValueIsBetween(csv, "syst-tr", 0, syst_t); - checkValueIsBetween(csv, "syst-tb", 0, syst_t); // Cgroup // We may not always show this. But if we do, at least the usage numbers should be checked From 19600fbf01fe8468c9d72daccff639f83e22935e Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Mon, 28 Sep 2026 08:13:00 +0200 Subject: [PATCH 02/11] Reactivated code i disabled for testing. --- test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java b/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java index 096590844d4d..620a3e41620c 100644 --- a/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java +++ b/test/hotspot/jtreg/runtime/Vitals/VitalsUtils.java @@ -74,7 +74,7 @@ static int matchPatterns(String[] lines, int startAtLine, String[] regexes) { } if (nextToMatch < regexes.length) { throw new RuntimeException("Not all matches found. First missing pattern " + nextToMatch + ":" + regexes[nextToMatch] + - "\nOutput: " /* + String.join("\n", lines)*/); + "\nOutput: " + String.join("\n", lines)); } return nLine; } From e6ebb692204ec93fb115a29bd4b79ca5601cf0af Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Mon, 28 Sep 2026 08:17:01 +0200 Subject: [PATCH 03/11] Cosmentic changes. --- src/hotspot/os/linux/os_linux.cpp | 2 +- src/hotspot/os/linux/os_linux.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 75d1737769d8..2ac748d1b1e7 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -2489,7 +2489,7 @@ bool os::Linux::get_total_procs_and_threads(uint64_t* procs, uint64_t* threads) if (is_numerical_id(en->d_name)) { procs_count++; if (threads == nullptr) { - continue; + continue; } char tmp[128]; jio_snprintf(tmp, sizeof(tmp), "/proc/%s/stat", en->d_name); diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index 5e2ce3c4b8d5..b0ccd3f1ade4 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -188,7 +188,7 @@ class os::Linux { static bool query_accurate_process_memory_info(accurate_meminfo_t* info); // Gets the total number of processes and threads on the system. If parameter is nullptr - // the value isn't determined. This is useful since the thread count is somewhat expensivce. + // the value isn't determined. This is useful since the thread count is somewhat expensive. static bool get_total_procs_and_threads(uint64_t* procs, uint64_t* threads); // Tells if the user asked for transparent huge pages. From 71930918f35ed5b567b70fa1ebed3d9a86ad2d0a Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Tue, 29 Sep 2026 11:20:29 +0200 Subject: [PATCH 04/11] Remove warning --- src/hotspot/os/linux/os_linux.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 2ac748d1b1e7..21c821c6ca95 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -2498,8 +2498,9 @@ bool os::Linux::get_total_procs_and_threads(uint64_t* procs, uint64_t* threads) // See man proc(5) // (20) num_threads %ld long num_threads = 0; - ::fscanf(fp, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld", &num_threads); - threads_count += num_threads; + if (fscanf(fp, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld", &num_threads) == 1) { + threads_count += num_threads; + } ::fclose(fp); } } From cc6af1c92ac51a7124fb89491f3191524af405ec Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Tue, 29 Sep 2026 11:47:37 +0200 Subject: [PATCH 05/11] Added missing include --- src/hotspot/os/linux/vitals_linux_oswrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp index 7e824d49e4d2..90595c384b99 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp @@ -24,6 +24,7 @@ */ #include "jvm_io.h" +#include "os_linux.hpp" #include "logging/log.hpp" #include "osContainer_linux.hpp" #include "runtime/os.hpp" From 3828b26246ebfc0397647a66aa2cc6ac9f3bdef5 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Tue, 29 Sep 2026 12:16:09 +0200 Subject: [PATCH 06/11] Include sort order --- src/hotspot/os/linux/vitals_linux_oswrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp index 90595c384b99..efff8a57462d 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp @@ -24,8 +24,8 @@ */ #include "jvm_io.h" -#include "os_linux.hpp" #include "logging/log.hpp" +#include "os_linux.hpp" #include "osContainer_linux.hpp" #include "runtime/os.hpp" #include "utilities/globalDefinitions.hpp" From 334d8db32f536fcb7d1fa3b1d5999b9c224f5af7 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Wed, 30 Sep 2026 16:47:27 +0200 Subject: [PATCH 07/11] Adapt test to later start of sampling. --- .../jtreg/runtime/Vitals/VitalsValuesSanityCheck.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java b/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java index 912dfd9f185d..ceb7ec0dc613 100644 --- a/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java +++ b/test/hotspot/jtreg/runtime/Vitals/VitalsValuesSanityCheck.java @@ -63,6 +63,9 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Proxy; +import java.net.URL; +import java.net.URLClassLoader; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -355,7 +358,11 @@ public void jmx() { try { // wait some time. We sample with 1sec sample frequency, that should give us more than one sample // and therefore some of them should show delta values - Thread.sleep(4000); + for (int i = 0; i < 400; ++i) { + // Load some classes. + Proxy.getProxyClass(new URLClassLoader(new URL[0]), new Class [] { CharSequence.class }); + Thread.sleep(10); + } } catch (InterruptedException e) { e.printStackTrace(); } From 960208a99d28ba62007f96ac069f19fdc7e4d214 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Thu, 1 Oct 2026 07:12:13 +0200 Subject: [PATCH 08/11] Removed overeager adjustments to copyright dates --- src/hotspot/os/linux/vitals_linux_himemreport.cpp | 2 +- src/hotspot/os/linux/vitals_linux_himemreport.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.cpp b/src/hotspot/os/linux/vitals_linux_himemreport.cpp index 94dfacffa07d..bc78ee9a54de 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.cpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2026 SAP SE. All rights reserved. + * Copyright (c) 2022 SAP SE. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.hpp b/src/hotspot/os/linux/vitals_linux_himemreport.hpp index 318ca594dda7..188edf7c6d3d 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.hpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2026 SAP SE. All rights reserved. + * Copyright (c) 2022, 2025 SAP SE. All rights reserved. * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. From 1d9150f1441087530c65680f554aa97474690093 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Thu, 1 Oct 2026 07:17:39 +0200 Subject: [PATCH 09/11] Removed overeager adjustments to copyright dates, second try --- src/hotspot/os/linux/vitals_linux_himemreport.cpp | 2 +- src/hotspot/os/linux/vitals_linux_himemreport.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.cpp b/src/hotspot/os/linux/vitals_linux_himemreport.cpp index bc78ee9a54de..86e68fce0b32 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.cpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 SAP SE. All rights reserved. + * Copyright (c) 2022, 2025 SAP SE. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/src/hotspot/os/linux/vitals_linux_himemreport.hpp b/src/hotspot/os/linux/vitals_linux_himemreport.hpp index 188edf7c6d3d..cc173b1b853b 100644 --- a/src/hotspot/os/linux/vitals_linux_himemreport.hpp +++ b/src/hotspot/os/linux/vitals_linux_himemreport.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025 SAP SE. All rights reserved. + * Copyright (c) 2022 SAP SE. All rights reserved. * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. From f56c7a9d2c4157494c213070ff49ee2777fe1662 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Thu, 1 Oct 2026 15:27:00 +0200 Subject: [PATCH 10/11] Add missing SapMachine tags. --- src/hotspot/os/linux/os_linux.cpp | 7 +++++-- src/hotspot/os/linux/os_linux.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 21c821c6ca95..6a2f41f663cc 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1155,8 +1155,10 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread \"%s\" - pthread_create failed (%s) for attributes: %s.", thread->name(), os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); - // Log some OS information which might explain why creating the thread failed. Since this - // is a lot of output we only use warning level first and then turn it down to Info. + // Log some OS information which might explain why creating the thread failed. + + // SapMachine 2026-10-01: Since this is a lot of output we only use warning level first and + // then turn it down to Info. static bool is_first = true; if (is_first || log_is_enabled(Info, os, thread)) { @@ -2476,6 +2478,7 @@ static bool is_numerical_id(const char* s) { return *p == '\0' ? true : false; } +// SapMachine 2026-10-01 bool os::Linux::get_total_procs_and_threads(uint64_t* procs, uint64_t* threads) { TraceTime timer("Iterating all processes", TRACETIME_LOG(Trace, os, timer)); DIR* d = ::opendir("/proc"); diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index b0ccd3f1ade4..5b7259f2c24c 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -187,7 +187,7 @@ class os::Linux { // fields will contain -1. static bool query_accurate_process_memory_info(accurate_meminfo_t* info); - // Gets the total number of processes and threads on the system. If parameter is nullptr + // SapMachine 2026-10-01: Gets the total number of processes and threads on the system. If a parameter is nullptr // the value isn't determined. This is useful since the thread count is somewhat expensive. static bool get_total_procs_and_threads(uint64_t* procs, uint64_t* threads); From b37383b24434bb3925112c642ee344740880804e Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Mon, 5 Oct 2026 08:59:27 +0200 Subject: [PATCH 11/11] Add mising SapMachine tag --- src/hotspot/os/linux/os_linux.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 6a2f41f663cc..b5c2de51044d 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -61,6 +61,7 @@ #include "runtime/threads.hpp" #include "runtime/threadSMR.hpp" #include "runtime/timer.hpp" +// SapMachine 2026-10-01 #include "runtime/timerTrace.hpp" #include "runtime/vm_version.hpp" #include "semaphore_posix.hpp"