Skip to content

Commit

Permalink
Merge branch 'ms-patches/use-all-windows-processor-groups' into relea…
Browse files Browse the repository at this point in the history
…se/jdk-17.0.13-ga
  • Loading branch information
Java Platform Infrastructure committed Oct 15, 2024
2 parents ccf81ae + edd7c4e commit 2addbbb
Show file tree
Hide file tree
Showing 11 changed files with 733 additions and 68 deletions.
2 changes: 2 additions & 0 deletions make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,8 @@ else
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libterminatedThread += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit += -ljvm
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread

BUILD_HOTSPOT_JTREG_EXCLUDE += exeGetProcessorInfo.c
endif

# This evaluation is expensive and should only be done if this target was
Expand Down
10 changes: 10 additions & 0 deletions ms-patches/use-all-windows-processor-groups-6942632.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Hotspot should be able to use more than 64 logical processors on Windows
- work_item: 2114222
- jbs_bug: JDK-6942632
- author: swesonga
- owner: swesonga
- contributors:
- details:
- Backport of https://github.com/openjdk/jdk/pull/17576.
- release_note:
- Enables Hotspot to use processors across all Windows processor groups on Windows 11/Windows Server 2022 and later.
3 changes: 3 additions & 0 deletions src/hotspot/os/windows/globals_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
range, \
constraint) \
\
product(bool, UseAllWindowsProcessorGroups, false, \
"Use all processor groups on supported Windows versions") \
\
product(bool, UseOSErrorReporting, false, \
"Let VM fatal error propagate to the OS (ie. WER on Windows)")

Expand Down
368 changes: 300 additions & 68 deletions src/hotspot/os/windows/os_windows.cpp

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions src/hotspot/os/windows/os_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class win32 {
static size_t _default_stack_size;
static bool _is_windows_server;
static bool _has_exit_bug;
static bool _processor_group_warning_displayed;
static bool _job_object_processor_group_warning_displayed;

static int _major_version;
static int _minor_version;
static int _build_number;
static int _build_minor;

static void print_windows_version(outputStream* st);
static void print_uptime_info(outputStream* st);
Expand All @@ -61,6 +68,37 @@ class win32 {
// Windows-specific interface:
static void initialize_system_info();
static void setmode_streams();
static bool is_windows_11_or_greater();
static bool is_windows_server_2022_or_greater();
static int windows_major_version() {
assert(_major_version > 0, "windows version not initialized.");
return _major_version;
}
static int windows_minor_version() {
assert(_major_version > 0, "windows version not initialized.");
return _minor_version;
}
static int windows_build_number() {
assert(_major_version > 0, "windows version not initialized.");
return _build_number;
}
static int windows_build_minor() {
assert(_major_version > 0, "windows version not initialized.");
return _build_minor;
}

static void set_processor_group_warning_displayed(bool displayed) {
_processor_group_warning_displayed = displayed;
}
static bool processor_group_warning_displayed() {
return _processor_group_warning_displayed;
}
static void set_job_object_processor_group_warning_displayed(bool displayed) {
_job_object_processor_group_warning_displayed = displayed;
}
static bool job_object_processor_group_warning_displayed() {
return _job_object_processor_group_warning_displayed;
}

// Processor info as provided by NT
static int processor_type() { return _processor_type; }
Expand All @@ -79,6 +117,8 @@ class win32 {
static int exit_process_or_thread(Ept what, int exit_code);

static void initialize_performance_counter();
static void initialize_windows_version();
static DWORD active_processors_in_job_object(DWORD* active_processor_groups = nullptr);

public:
// Generic interface:
Expand Down
19 changes: 19 additions & 0 deletions test/hotspot/gtest/runtime/test_os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,25 @@ TEST_VM(os_windows, reserve_memory_special) {
TestReserveMemorySpecial_test();
}

TEST_VM(os_windows, processor_count) {
JVMFlag* flag = JVMFlag::find_flag("UseAllWindowsProcessorGroups");
EXPECT_NE(flag, nullptr) << "Expected UseAllWindowsProcessorGroups product flag to be available";

int processors = os::processor_count();
EXPECT_GT(processors, 0) << "Expected at least 1 processor";

int active_processors = os::active_processor_count();
EXPECT_GT(active_processors, 0) << "Expected at least 1 active processor";

bool schedules_all_processor_groups = os::win32::is_windows_11_or_greater() || os::win32::is_windows_server_2022_or_greater();
if (schedules_all_processor_groups && UseAllWindowsProcessorGroups) {
EXPECT_EQ(active_processors, processors) << "Expected all processors to be active";
} else {
// active_processors should be at most the number of processors in 1 Windows processor group.
EXPECT_LE(active_processors, processors) << "Expected active processors to not exceed available processors";
}
}

class ReserveMemorySpecialRunnable : public TestRunnable {
public:
void runUnitTest() const {
Expand Down
1 change: 1 addition & 0 deletions test/hotspot/jtreg/TEST.groups
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ tier1_common = \
gtest/MetaspaceGtests.java \
gtest/LargePageGtests.java \
gtest/NMTGtests.java \
gtest/WindowsProcessorGroups.java

tier1_compiler = \
:tier1_compiler_1 \
Expand Down
34 changes: 34 additions & 0 deletions test/hotspot/jtreg/gtest/WindowsProcessorGroups.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

/*
* This runs the os related gtests on Windows with all processor groups enabled.
*/

/* @test id=use-all-windows-processor-groups
* @summary Run gtests with all Windows processor groups enabled
* @library /test/lib
* @requires os.family == "windows"
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseAllWindowsProcessorGroups
*/
29 changes: 29 additions & 0 deletions test/hotspot/jtreg/runtime/os/windows/GetAvailableProcessors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

public class GetAvailableProcessors {
public static void main(String[] args) {
System.out.println("Runtime.availableProcessors: " + Runtime.getRuntime().availableProcessors());
}
}
Loading

0 comments on commit 2addbbb

Please sign in to comment.