Skip to content

Commit ae72b52

Browse files
committed
8255047: Add HotSpot UseDebuggerErgo flags
Reviewed-by: dcubed, dholmes
1 parent 211bb62 commit ae72b52

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

src/hotspot/os/linux/globals_linux.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"be dumped into the corefile.") \
8080
\
8181
product(bool, UseCpuAllocPath, false, DIAGNOSTIC, \
82-
"Use CPU_ALLOC code path in os::active_processor_count ")
82+
"Use CPU_ALLOC code path in os::active_processor_count ")
8383

8484
// end of RUNTIME_OS_FLAGS
8585

src/hotspot/os/linux/os_linux.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,17 @@ void os::Linux::rebuild_cpu_to_node_map() {
32173217
if (cpu_map[j] != 0) {
32183218
for (size_t k = 0; k < BitsPerCLong; k++) {
32193219
if (cpu_map[j] & (1UL << k)) {
3220-
cpu_to_node()->at_put(j * BitsPerCLong + k, closest_node);
3220+
int cpu_index = j * BitsPerCLong + k;
3221+
3222+
#ifndef PRODUCT
3223+
if (UseDebuggerErgo1 && cpu_index >= (int)cpu_num) {
3224+
// Some debuggers limit the processor count without
3225+
// intercepting the NUMA APIs. Just fake the values.
3226+
cpu_index = 0;
3227+
}
3228+
#endif
3229+
3230+
cpu_to_node()->at_put(cpu_index, closest_node);
32213231
}
32223232
}
32233233
}
@@ -4762,7 +4772,16 @@ int os::active_processor_count() {
47624772

47634773
uint os::processor_id() {
47644774
const int id = Linux::sched_getcpu();
4765-
assert(id >= 0 && id < _processor_count, "Invalid processor id");
4775+
4776+
#ifndef PRODUCT
4777+
if (UseDebuggerErgo1 && id >= _processor_count) {
4778+
// Some debuggers limit the processor count without limiting
4779+
// the returned processor ids. Fake the processor id.
4780+
return 0;
4781+
}
4782+
#endif
4783+
4784+
assert(id >= 0 && id < _processor_count, "Invalid processor id [%d]", id);
47664785
return (uint)id;
47674786
}
47684787

src/hotspot/share/runtime/arguments.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,6 +3901,22 @@ bool Arguments::handle_deprecated_print_gc_flags() {
39013901
return true;
39023902
}
39033903

3904+
static void apply_debugger_ergo() {
3905+
if (UseDebuggerErgo) {
3906+
// Turn on sub-flags
3907+
FLAG_SET_ERGO_IF_DEFAULT(UseDebuggerErgo1, true);
3908+
FLAG_SET_ERGO_IF_DEFAULT(UseDebuggerErgo2, true);
3909+
}
3910+
3911+
if (UseDebuggerErgo2) {
3912+
// Debugging with limited number of CPUs
3913+
FLAG_SET_ERGO_IF_DEFAULT(UseNUMA, false);
3914+
FLAG_SET_ERGO_IF_DEFAULT(ConcGCThreads, 1);
3915+
FLAG_SET_ERGO_IF_DEFAULT(ParallelGCThreads, 1);
3916+
FLAG_SET_ERGO_IF_DEFAULT(CICompilerCount, 2);
3917+
}
3918+
}
3919+
39043920
// Parse entry point called from JNI_CreateJavaVM
39053921

39063922
jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
@@ -4097,6 +4113,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
40974113
}
40984114
#endif
40994115

4116+
apply_debugger_ergo();
4117+
41004118
return JNI_OK;
41014119
}
41024120

src/hotspot/share/runtime/globals.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,17 @@ const intx ObjectAlignmentInBytes = 8;
22072207
product(bool, UseNewCode3, false, DIAGNOSTIC, \
22082208
"Testing Only: Use the new version while testing") \
22092209
\
2210+
notproduct(bool, UseDebuggerErgo, false, \
2211+
"Debugging Only: Adjust the VM to be more debugger-friendly. " \
2212+
"Turns on the other UseDebuggerErgo* flags") \
2213+
\
2214+
notproduct(bool, UseDebuggerErgo1, false, \
2215+
"Debugging Only: Enable workarounds for debugger induced " \
2216+
"os::processor_id() >= os::processor_count() problems") \
2217+
\
2218+
notproduct(bool, UseDebuggerErgo2, false, \
2219+
"Debugging Only: Limit the number of spawned JVM threads") \
2220+
\
22102221
/* flags for performance data collection */ \
22112222
\
22122223
product(bool, UsePerfData, true, \

0 commit comments

Comments
 (0)