Thu, 25 Aug 2011 02:57:46 -0700
7082969: NUMA interleaving
Summary: Support interleaving on NUMA systems for collectors that don't have NUMA-awareness.
Reviewed-by: iveresov, ysr
Contributed-by: Tom Deneau <tom.deneau@amd.com>
1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #ifndef OS_WINDOWS_VM_OS_WINDOWS_HPP
26 #define OS_WINDOWS_VM_OS_WINDOWS_HPP
27 // Win32_OS defines the interface to windows operating systems
29 class win32 {
31 protected:
32 static int _vm_page_size;
33 static int _vm_allocation_granularity;
34 static int _processor_type;
35 static int _processor_level;
36 static julong _physical_memory;
37 static size_t _default_stack_size;
38 static bool _is_nt;
39 static bool _is_windows_2003;
40 static bool _is_windows_server;
42 public:
43 // Windows-specific interface:
44 static void initialize_system_info();
45 static void setmode_streams();
47 // Processor info as provided by NT
48 static int processor_type() { return _processor_type; }
49 // Processor level may not be accurate on non-NT systems
50 static int processor_level() {
51 assert(is_nt(), "use vm_version instead");
52 return _processor_level;
53 }
54 static julong available_memory();
55 static julong physical_memory() { return _physical_memory; }
57 // load dll from Windows system directory or Windows directory
58 static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen);
60 public:
61 // Generic interface:
63 // Trace number of created threads
64 static intx _os_thread_limit;
65 static volatile intx _os_thread_count;
67 // Tells whether the platform is NT or Windown95
68 static bool is_nt() { return _is_nt; }
70 // Tells whether this is a server version of Windows
71 static bool is_windows_server() { return _is_windows_server; }
73 // Tells whether the platform is Windows 2003
74 static bool is_windows_2003() { return _is_windows_2003; }
76 // Returns the byte size of a virtual memory page
77 static int vm_page_size() { return _vm_page_size; }
79 // Returns the size in bytes of memory blocks which can be allocated.
80 static int vm_allocation_granularity() { return _vm_allocation_granularity; }
82 // Read the headers for the executable that started the current process into
83 // the structure passed in (see winnt.h).
84 static void read_executable_headers(PIMAGE_NT_HEADERS);
86 // Default stack size for the current process.
87 static size_t default_stack_size() { return _default_stack_size; }
89 #ifndef _WIN64
90 // A wrapper to install a structured exception handler for fast JNI accesors.
91 static address fast_jni_accessor_wrapper(BasicType);
92 #endif
94 // filter function to ignore faults on serializations page
95 static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
96 };
98 class PlatformEvent : public CHeapObj {
99 private:
100 double CachePad [4] ; // increase odds that _Event is sole occupant of cache line
101 volatile int _Event ;
102 HANDLE _ParkHandle ;
104 public: // TODO-FIXME: make dtor private
105 ~PlatformEvent() { guarantee (0, "invariant") ; }
107 public:
108 PlatformEvent() {
109 _Event = 0 ;
110 _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
111 guarantee (_ParkHandle != NULL, "invariant") ;
112 }
114 // Exercise caution using reset() and fired() - they may require MEMBARs
115 void reset() { _Event = 0 ; }
116 int fired() { return _Event; }
117 void park () ;
118 void unpark () ;
119 int park (jlong millis) ;
120 } ;
124 class PlatformParker : public CHeapObj {
125 protected:
126 HANDLE _ParkEvent ;
128 public:
129 ~PlatformParker () { guarantee (0, "invariant") ; }
130 PlatformParker () {
131 _ParkEvent = CreateEvent (NULL, true, false, NULL) ;
132 guarantee (_ParkEvent != NULL, "invariant") ;
133 }
135 } ;
137 // JDK7 requires VS2010
138 #if _MSC_VER < 1600
139 #define JDK6_OR_EARLIER 1
140 #endif
144 class WinSock2Dll: AllStatic {
145 public:
146 static BOOL WSAStartup(WORD, LPWSADATA);
147 static struct hostent* gethostbyname(const char *name);
148 static BOOL WinSock2Available();
149 #ifdef JDK6_OR_EARLIER
150 private:
151 static int (PASCAL FAR* _WSAStartup)(WORD, LPWSADATA);
152 static struct hostent *(PASCAL FAR *_gethostbyname)(...);
153 static BOOL initialized;
155 static void initialize();
156 #endif
157 };
159 class Kernel32Dll: AllStatic {
160 public:
161 static BOOL SwitchToThread();
162 static SIZE_T GetLargePageMinimum();
164 static BOOL SwitchToThreadAvailable();
165 static BOOL GetLargePageMinimumAvailable();
167 // Help tools
168 static BOOL HelpToolsAvailable();
169 static HANDLE CreateToolhelp32Snapshot(DWORD,DWORD);
170 static BOOL Module32First(HANDLE,LPMODULEENTRY32);
171 static BOOL Module32Next(HANDLE,LPMODULEENTRY32);
173 static BOOL GetNativeSystemInfoAvailable();
174 static void GetNativeSystemInfo(LPSYSTEM_INFO);
176 // NUMA calls
177 static BOOL NumaCallsAvailable();
178 static LPVOID VirtualAllocExNuma(HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
179 static BOOL GetNumaHighestNodeNumber(PULONG);
180 static BOOL GetNumaNodeProcessorMask(UCHAR, PULONGLONG);
182 private:
183 // GetLargePageMinimum available on Windows Vista/Windows Server 2003
184 // and later
185 // NUMA calls available Windows Vista/WS2008 and later
187 static SIZE_T (WINAPI *_GetLargePageMinimum)(void);
188 static LPVOID (WINAPI *_VirtualAllocExNuma) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
189 static BOOL (WINAPI *_GetNumaHighestNodeNumber) (PULONG);
190 static BOOL (WINAPI *_GetNumaNodeProcessorMask) (UCHAR, PULONGLONG);
191 static BOOL initialized;
193 static void initialize();
194 static void initializeCommon();
196 #ifdef JDK6_OR_EARLIER
197 private:
198 static BOOL (WINAPI *_SwitchToThread)(void);
199 static HANDLE (WINAPI* _CreateToolhelp32Snapshot)(DWORD,DWORD);
200 static BOOL (WINAPI* _Module32First)(HANDLE,LPMODULEENTRY32);
201 static BOOL (WINAPI* _Module32Next)(HANDLE,LPMODULEENTRY32);
202 static void (WINAPI *_GetNativeSystemInfo)(LPSYSTEM_INFO);
203 #endif
205 };
207 class Advapi32Dll: AllStatic {
208 public:
209 static BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
210 static BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE);
211 static BOOL LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID);
213 static BOOL AdvapiAvailable();
215 #ifdef JDK6_OR_EARLIER
216 private:
217 static BOOL (WINAPI *_AdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
218 static BOOL (WINAPI *_OpenProcessToken)(HANDLE, DWORD, PHANDLE);
219 static BOOL (WINAPI *_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID);
220 static BOOL initialized;
222 static void initialize();
223 #endif
224 };
226 class PSApiDll: AllStatic {
227 public:
228 static BOOL EnumProcessModules(HANDLE, HMODULE *, DWORD, LPDWORD);
229 static DWORD GetModuleFileNameEx(HANDLE, HMODULE, LPTSTR, DWORD);
230 static BOOL GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD);
232 static BOOL PSApiAvailable();
234 #ifdef JDK6_OR_EARLIER
235 private:
236 static BOOL (WINAPI *_EnumProcessModules)(HANDLE, HMODULE *, DWORD, LPDWORD);
237 static BOOL (WINAPI *_GetModuleFileNameEx)(HANDLE, HMODULE, LPTSTR, DWORD);;
238 static BOOL (WINAPI *_GetModuleInformation)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
239 static BOOL initialized;
241 static void initialize();
242 #endif
243 };
245 #endif // OS_WINDOWS_VM_OS_WINDOWS_HPP