diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4 index e057626b676d1..a50ce57318186 100644 --- a/make/autoconf/libraries.m4 +++ b/make/autoconf/libraries.m4 @@ -170,7 +170,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], if test "x$OPENJDK_TARGET_OS" = xwindows; then BASIC_JVM_LIBS="$BASIC_JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib powrprof.lib uuid.lib \ wsock32.lib winmm.lib version.lib psapi.lib" fi LIB_SETUP_JVM_LIBS(BUILD) diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index ed4d183b53526..282ff63a432b6 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1299,8 +1299,34 @@ void os::print_os_info(outputStream* st) { VM_Version::print_platform_virtualization_info(st); } +#ifdef __APPLE__ +static void print_sysctl_info_string(const char* sysctlkey, outputStream* st, char* buf, size_t size) { + if (sysctlbyname(sysctlkey, buf, &size, NULL, 0) >= 0) { + st->print_cr("%s:%s", sysctlkey, buf); + } +} + +static void print_sysctl_info_uint64(const char* sysctlkey, outputStream* st) { + uint64_t val; + size_t size=sizeof(uint64_t); + if (sysctlbyname(sysctlkey, &val, &size, NULL, 0) >= 0) { + st->print_cr("%s:%llu", sysctlkey, val); + } +} +#endif + void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { - // Nothing to do for now. +#ifdef __APPLE__ + print_sysctl_info_string("machdep.cpu.brand_string", st, buf, buflen); + print_sysctl_info_uint64("hw.cpufrequency", st); + print_sysctl_info_uint64("hw.cpufrequency_min", st); + print_sysctl_info_uint64("hw.cpufrequency_max", st); + print_sysctl_info_uint64("hw.cachelinesize", st); + print_sysctl_info_uint64("hw.l1icachesize", st); + print_sysctl_info_uint64("hw.l1dcachesize", st); + print_sysctl_info_uint64("hw.l2cachesize", st); + print_sysctl_info_uint64("hw.l3cachesize", st); +#endif } void os::get_summary_cpu_info(char* buf, size_t buflen) { diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 00148c043089c..b3ba21027bdfe 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -91,6 +91,7 @@ #include #include +#include #include #include #include @@ -1876,8 +1877,65 @@ void os::win32::print_windows_version(outputStream* st) { st->cr(); } +// Processor Power Information; missing from Windows headers +typedef struct _PROCESSOR_POWER_INFORMATION { + ULONG Number; + ULONG MaxMhz; // max specified clock frequency of the system processor + ULONG CurrentMhz; // max specified processor clock frequency mult. by current processor throttle + ULONG MhzLimit; // max specified processor clock frequency mult. by current processor thermal throttle limit + ULONG MaxIdleState; + ULONG CurrentIdleState; +} PROCESSOR_POWER_INFORMATION; + void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { - // Nothing to do for now. + int proc_count = os::processor_count(); + // handle potential early cases where processor count is not yet set + if (proc_count < 1) { + SYSTEM_INFO si; + GetSystemInfo(&si); + proc_count = si.dwNumberOfProcessors; + } + + size_t sz_check = sizeof(PROCESSOR_POWER_INFORMATION) * (size_t)proc_count; + NTSTATUS status = ::CallNtPowerInformation(ProcessorInformation, NULL, 0, buf, (ULONG) buflen); + int max_mhz = -1, current_mhz = -1, mhz_limit = -1; + bool same_vals_for_all_cpus = true; + + if (status == ERROR_SUCCESS) { + PROCESSOR_POWER_INFORMATION* pppi = (PROCESSOR_POWER_INFORMATION*) buf; + for (int i = 0; i < proc_count; i++) { + if (i == 0) { + max_mhz = (int) pppi->MaxMhz; + current_mhz = (int) pppi->CurrentMhz; + mhz_limit = (int) pppi->MhzLimit; + } else { + if (max_mhz != (int) pppi->MaxMhz || + current_mhz != (int) pppi->CurrentMhz || + mhz_limit != (int) pppi->MhzLimit) { + same_vals_for_all_cpus = false; + break; + } + } + // avoid iteration in case buf is too small to hold all proc infos + if (sz_check > buflen) break; + pppi++; + } + + if (same_vals_for_all_cpus && max_mhz != -1) { + st->print_cr("Processor Information for all %d processors :", proc_count); + st->print_cr(" Max Mhz: %d, Current Mhz: %d, Mhz Limit: %d", max_mhz, current_mhz, mhz_limit); + return; + } + // differing values, iterate again + pppi = (PROCESSOR_POWER_INFORMATION*) buf; + for (int i = 0; i < proc_count; i++) { + st->print_cr("Processor Information for processor %d", (int) pppi->Number); + st->print_cr(" Max Mhz: %d, Current Mhz: %d, Mhz Limit: %d", + (int) pppi->MaxMhz, (int) pppi->CurrentMhz, (int) pppi->MhzLimit); + if (sz_check > buflen) break; + pppi++; + } + } } void os::get_summary_cpu_info(char* buf, size_t buflen) {