8175817: Clean up Solaris signal code: SIGUSR2, SIGasync, SIGJVM1/2
Reviewed-by: rehn, stuefe, dsamersoff
--- a/hotspot/src/os/solaris/vm/jvm_solaris.h Fri Mar 17 15:26:49 2017 +0000
+++ b/hotspot/src/os/solaris/vm/jvm_solaris.h Sun Mar 19 16:40:09 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -85,7 +85,7 @@
/* Signal definitions */
#define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */
-#define ASYNC_SIGNAL SIGUSR2 /* Watcher & async err support. */
+#define ASYNC_SIGNAL SIGJVM2 /* Event-based suspend/resume support */
#define SHUTDOWN1_SIGNAL SIGHUP /* Shutdown Hooks support. */
#define SHUTDOWN2_SIGNAL SIGINT
#define SHUTDOWN3_SIGNAL SIGTERM
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Fri Mar 17 15:26:49 2017 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Sun Mar 19 16:40:09 2017 -0400
@@ -1013,21 +1013,9 @@
return true;
}
-// defined for >= Solaris 10. This allows builds on earlier versions
-// of Solaris to take advantage of the newly reserved Solaris JVM signals.
-// With SIGJVM1, SIGJVM2, ASYNC_SIGNAL is SIGJVM2. Previously INTERRUPT_SIGNAL
-// was SIGJVM1.
-//
-#if !defined(SIGJVM1)
- #define SIGJVM1 39
- #define SIGJVM2 40
-#endif
-
debug_only(static bool signal_sets_initialized = false);
static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs;
-int os::Solaris::_SIGasync = ASYNC_SIGNAL;
-
bool os::Solaris::is_sig_ignored(int sig) {
struct sigaction oact;
sigaction(sig, (struct sigaction*)NULL, &oact);
@@ -1040,12 +1028,6 @@
}
}
-// Note: SIGRTMIN is a macro that calls sysconf() so it will
-// dynamically detect SIGRTMIN value for the system at runtime, not buildtime
-static bool isJVM1available() {
- return SIGJVM1 < SIGRTMIN;
-}
-
void os::Solaris::signal_sets_init() {
// Should also have an assertion stating we are still single-threaded.
assert(!signal_sets_initialized, "Already initialized");
@@ -1068,12 +1050,7 @@
sigaddset(&unblocked_sigs, SIGSEGV);
sigaddset(&unblocked_sigs, SIGBUS);
sigaddset(&unblocked_sigs, SIGFPE);
-
- // Always true on Solaris 10+
- guarantee(isJVM1available(), "SIGJVM1/2 missing!");
- os::Solaris::set_SIGasync(SIGJVM2);
-
- sigaddset(&unblocked_sigs, os::Solaris::SIGasync());
+ sigaddset(&unblocked_sigs, ASYNC_SIGNAL);
if (!ReduceSignalUsage) {
if (!os::Solaris::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
@@ -1918,7 +1895,6 @@
// Moved from whole group, because we need them here for diagnostic
// prints.
-#define OLDMAXSIGNUM 32
static int Maxsignum = 0;
static int *ourSigFlags = NULL;
@@ -2011,7 +1987,6 @@
print_signal_handler(st, SHUTDOWN1_SIGNAL , buf, buflen);
print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
print_signal_handler(st, SHUTDOWN3_SIGNAL, buf, buflen);
- print_signal_handler(st, os::Solaris::SIGasync(), buf, buflen);
}
static char saved_jvm_path[MAXPATHLEN] = { 0 };
@@ -2179,14 +2154,12 @@
// a counter for each possible signal value
static int Sigexit = 0;
-static int Maxlibjsigsigs;
static jint *pending_signals = NULL;
static int *preinstalled_sigs = NULL;
static struct sigaction *chainedsigactions = NULL;
static sema_t sig_sem;
typedef int (*version_getting_t)();
version_getting_t os::Solaris::get_libjsig_version = NULL;
-static int libjsigversion = NULL;
int os::sigexitnum_pd() {
assert(Sigexit > 0, "signal memory not yet initialized");
@@ -2199,8 +2172,6 @@
Sigexit = Maxsignum+1;
assert(Maxsignum >0, "Unable to obtain max signal number");
- Maxlibjsigsigs = Maxsignum;
-
// pending_signals has one int per signal
// The additional signal is for SIGEXIT - exit signal to signal_thread
pending_signals = (jint *)os::malloc(sizeof(jint) * (Sigexit+1), mtInternal);
@@ -3564,7 +3535,7 @@
// get current set of blocked signals and unblock resume signal
pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
- sigdelset(&suspend_set, os::Solaris::SIGasync());
+ sigdelset(&suspend_set, ASYNC_SIGNAL);
sr_semaphore.signal();
// wait here until we are resumed
@@ -3619,7 +3590,7 @@
}
static int sr_notify(OSThread* osthread) {
- int status = thr_kill(osthread->thread_id(), os::Solaris::SIGasync());
+ int status = thr_kill(osthread->thread_id(), ASYNC_SIGNAL);
assert_status(status == 0, status, "thr_kill");
return status;
}
@@ -3764,7 +3735,7 @@
//
// This routine may recognize any of the following kinds of signals:
// SIGBUS, SIGSEGV, SIGILL, SIGFPE, BREAK_SIGNAL, SIGPIPE, SIGXFSZ,
-// os::Solaris::SIGasync
+// ASYNC_SIGNAL.
// It should be consulted by handlers for any of those signals.
//
// The caller of this routine must pass in the three arguments supplied
@@ -3799,7 +3770,7 @@
struct sigaction* os::Solaris::get_chained_signal_action(int sig) {
struct sigaction *actp = NULL;
- if ((libjsig_is_loaded) && (sig <= Maxlibjsigsigs)) {
+ if ((libjsig_is_loaded) && (sig <= Maxsignum)) {
// Retrieve the old signal handler from libjsig
actp = (*get_signal_action)(sig);
}
@@ -3964,6 +3935,7 @@
DO_SIGNAL_CHECK(SIGBUS);
DO_SIGNAL_CHECK(SIGPIPE);
DO_SIGNAL_CHECK(SIGXFSZ);
+ DO_SIGNAL_CHECK(ASYNC_SIGNAL);
// ReduceSignalUsage allows the user to override these handlers
// see comments at the very top and jvm_solaris.h
@@ -3973,10 +3945,6 @@
DO_SIGNAL_CHECK(SHUTDOWN3_SIGNAL);
DO_SIGNAL_CHECK(BREAK_SIGNAL);
}
-
- // See comments above for using JVM1/JVM2
- DO_SIGNAL_CHECK(os::Solaris::SIGasync());
-
}
typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *);
@@ -4008,6 +3976,7 @@
case SIGPIPE:
case SIGXFSZ:
case SIGILL:
+ case ASYNC_SIGNAL:
jvmHandler = CAST_FROM_FN_PTR(address, signalHandler);
break;
@@ -4019,16 +3988,8 @@
break;
default:
- int asynsig = os::Solaris::SIGasync();
-
- if (sig == asynsig) {
- jvmHandler = CAST_FROM_FN_PTR(address, signalHandler);
- } else {
return;
- }
- break;
- }
-
+ }
if (thisHandler != jvmHandler) {
tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN));
@@ -4061,7 +4022,6 @@
}
void os::Solaris::install_signal_handlers() {
- bool libjsigdone = false;
signal_handlers_are_installed = true;
// signal-chaining
@@ -4079,7 +4039,8 @@
dlsym(RTLD_DEFAULT, "JVM_get_libjsig_version"));
libjsig_is_loaded = true;
if (os::Solaris::get_libjsig_version != NULL) {
- libjsigversion = (*os::Solaris::get_libjsig_version)();
+ int libjsigversion = (*os::Solaris::get_libjsig_version)();
+ assert(libjsigversion == JSIG_VERSION_1_4_1, "libjsig version mismatch");
}
assert(UseSignalChaining, "should enable signal-chaining");
}
@@ -4094,21 +4055,9 @@
set_signal_handler(SIGBUS, true, true);
set_signal_handler(SIGILL, true, true);
set_signal_handler(SIGFPE, true, true);
-
-
- if (os::Solaris::SIGasync() > OLDMAXSIGNUM) {
- // Pre-1.4.1 Libjsig limited to signal chaining signals <= 32 so
- // can not register overridable signals which might be > 32
- if (libjsig_is_loaded && libjsigversion <= JSIG_VERSION_1_4_1) {
- // Tell libjsig jvm has finished setting signal handlers
- (*end_signal_setting)();
- libjsigdone = true;
- }
- }
-
- set_signal_handler(os::Solaris::SIGasync(), true, true);
-
- if (libjsig_is_loaded && !libjsigdone) {
+ set_signal_handler(ASYNC_SIGNAL, true, true);
+
+ if (libjsig_is_loaded) {
// Tell libjsig jvm finishes setting signal handlers
(*end_signal_setting)();
}
@@ -4408,10 +4357,6 @@
Solaris::init_signal_mem();
Solaris::install_signal_handlers();
- if (libjsigversion < JSIG_VERSION_1_4_1) {
- Maxlibjsigsigs = OLDMAXSIGNUM;
- }
-
// initialize synchronization primitives to use either thread or
// lwp synchronization (controlled by UseLWPSynchronization)
Solaris::synchronization_init();
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp Fri Mar 17 15:26:49 2017 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.hpp Sun Mar 19 16:40:09 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -109,9 +109,6 @@
static int (*get_libjsig_version)();
static void save_preinstalled_handler(int, struct sigaction&);
static void check_signal_handler(int sig);
- // For overridable signals
- static int _SIGasync; // user-overridable ASYNC_SIGNAL
- static void set_SIGasync(int newsig) { _SIGasync = newsig; }
typedef int (*pthread_setname_np_func_t)(pthread_t, const char*);
static pthread_setname_np_func_t _pthread_setname_np;
@@ -120,7 +117,6 @@
// Large Page Support--ISM.
static bool largepage_range(char* addr, size_t size);
- static int SIGasync() { return _SIGasync; }
static address handler_start, handler_end; // start and end pc of thr_sighndlrinfo
static bool valid_stack_address(Thread* thread, address sp);
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Fri Mar 17 15:26:49 2017 +0000
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Sun Mar 19 16:40:09 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -362,14 +362,14 @@
}
}
- if (sig == os::Solaris::SIGasync()) {
+ if (sig == ASYNC_SIGNAL) {
if (thread || vmthread) {
OSThread::SR_handler(t, uc);
return true;
} else if (os::Solaris::chained_handler(sig, info, ucVoid)) {
return true;
} else {
- // If os::Solaris::SIGasync not chained, and this is a non-vm and
+ // If ASYNC_SIGNAL not chained, and this is a non-vm and
// non-java thread
return true;
}
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Mar 17 15:26:49 2017 +0000
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Sun Mar 19 16:40:09 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -437,14 +437,14 @@
}
}
- if (sig == os::Solaris::SIGasync()) {
+ if (sig == ASYNC_SIGNAL) {
if(thread || vmthread){
OSThread::SR_handler(t, uc);
return true;
} else if (os::Solaris::chained_handler(sig, info, ucVoid)) {
return true;
} else {
- // If os::Solaris::SIGasync not chained, and this is a non-vm and
+ // If ASYNC_SIGNAL not chained, and this is a non-vm and
// non-java thread
return true;
}