Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys Pull up following revision(s) (requested by kamil in ...
details: https://anonhg.NetBSD.org/src/rev/406aa8798377
branches: netbsd-9
changeset: 462665:406aa8798377
user: martin <martin%NetBSD.org@localhost>
date: Tue Oct 15 19:23:09 2019 +0000
description:
Pull up following revision(s) (requested by kamil in ticket #328):
sys/kern/kern_sig.c: revision 1.369
sys/sys/signalvar.h: revision 1.97
Refactor sigswitch()
Make the function static as it is now local to kern_sig.c.
Rename the 'relock' argument to 'proc_lock_held' as it is more verbose.
This was suggested by mjg@freebsd. While there this flips the users between
true<->false.
Add additional KASSERT(9) calls here to validate whethe proc_lock is used
accordingly.
diffstat:
sys/kern/kern_sig.c | 38 +++++++++++++++++++++++---------------
sys/sys/signalvar.h | 3 +--
2 files changed, 24 insertions(+), 17 deletions(-)
diffs (174 lines):
diff -r c3b047c6883b -r 406aa8798377 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Tue Oct 15 19:13:22 2019 +0000
+++ b/sys/kern/kern_sig.c Tue Oct 15 19:23:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.364.2.3 2019/10/15 19:08:46 martin Exp $ */
+/* $NetBSD: kern_sig.c,v 1.364.2.4 2019/10/15 19:23:09 martin Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.3 2019/10/15 19:08:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.4 2019/10/15 19:23:09 martin Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@@ -125,6 +125,7 @@
static int sigpost(struct lwp *, sig_t, int, int);
static int sigput(sigpend_t *, struct proc *, ksiginfo_t *);
static int sigunwait(struct proc *, const ksiginfo_t *);
+static void sigswitch(int, int, bool);
static void sigacts_poolpage_free(struct pool *, void *);
static void *sigacts_poolpage_alloc(struct pool *, int);
@@ -931,7 +932,7 @@
* The process is already stopping.
*/
if ((p->p_sflag & PS_STOPPING) != 0) {
- sigswitch(0, p->p_xsig, false);
+ sigswitch(0, p->p_xsig, true);
mutex_enter(proc_lock);
mutex_enter(p->p_lock);
goto repeat; /* XXX */
@@ -949,7 +950,7 @@
p->p_sigctx.ps_faked = true;
p->p_sigctx.ps_lwp = ksi->ksi_lid;
p->p_sigctx.ps_info = ksi->ksi_info;
- sigswitch(0, signo, false);
+ sigswitch(0, signo, true);
if (ktrpoint(KTR_PSIG)) {
if (p->p_emul->e_ktrpsig)
@@ -1639,7 +1640,7 @@
* The process is already stopping.
*/
if ((p->p_sflag & PS_STOPPING) != 0) {
- sigswitch(0, p->p_xsig, false);
+ sigswitch(0, p->p_xsig, true);
mutex_enter(proc_lock);
mutex_enter(p->p_lock);
goto repeat; /* XXX */
@@ -1664,7 +1665,7 @@
p->p_sigctx.ps_lwp = ksi.ksi_lid;
p->p_sigctx.ps_info = ksi.ksi_info;
- sigswitch(0, signo, false);
+ sigswitch(0, signo, true);
if (code == TRAP_CHLD) {
mutex_enter(proc_lock);
@@ -1684,8 +1685,8 @@
/*
* Stop the current process and switch away when being stopped or traced.
*/
-void
-sigswitch(int ppmask, int signo, bool relock)
+static void
+sigswitch(int ppmask, int signo, bool proc_lock_held)
{
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
@@ -1695,6 +1696,12 @@
KASSERT(l->l_stat == LSONPROC);
KASSERT(p->p_nrlwps > 0);
+ if (proc_lock_held) {
+ KASSERT(mutex_owned(proc_lock));
+ } else {
+ KASSERT(!mutex_owned(proc_lock));
+ }
+
/*
* If we are exiting, demise now.
*
@@ -1702,7 +1709,7 @@
*/
if (__predict_false(ISSET(p->p_sflag, PS_WEXIT))) {
mutex_exit(p->p_lock);
- if (!relock) {
+ if (proc_lock_held) {
mutex_exit(proc_lock);
}
lwp_exit(l);
@@ -1726,7 +1733,7 @@
* a new signal, then signal the parent.
*/
if ((p->p_sflag & PS_STOPPING) != 0) {
- if (relock && !mutex_tryenter(proc_lock)) {
+ if (!proc_lock_held && !mutex_tryenter(proc_lock)) {
mutex_exit(p->p_lock);
mutex_enter(proc_lock);
mutex_enter(p->p_lock);
@@ -1746,6 +1753,7 @@
/*
* Unlock and switch away.
*/
+ KASSERT(!mutex_owned(proc_lock));
KERNEL_UNLOCK_ALL(l, &biglocks);
if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) {
p->p_nrlwps--;
@@ -1835,7 +1843,7 @@
* we awaken, check for a signal from the debugger.
*/
if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) {
- sigswitch(PS_NOCLDSTOP, 0, true);
+ sigswitch(PS_NOCLDSTOP, 0, false);
mutex_enter(p->p_lock);
signo = sigchecktrace();
} else if (p->p_stat == SACTIVE)
@@ -1907,7 +1915,7 @@
p->p_xsig = signo;
/* Handling of signal trace */
- sigswitch(0, signo, true);
+ sigswitch(0, signo, false);
mutex_enter(p->p_lock);
/* Check for a signal from the debugger. */
@@ -1964,7 +1972,7 @@
p->p_xsig = signo;
p->p_sflag &= ~PS_CONTINUED;
signo = 0;
- sigswitch(PS_NOCLDSTOP, p->p_xsig, true);
+ sigswitch(PS_NOCLDSTOP, p->p_xsig, false);
mutex_enter(p->p_lock);
} else if (prop & SA_IGNORE) {
/*
@@ -2517,7 +2525,7 @@
* The process is already stopping.
*/
if ((p->p_sflag & PS_STOPPING) != 0) {
- sigswitch(0, p->p_xsig, true);
+ sigswitch(0, p->p_xsig, false);
mutex_enter(p->p_lock);
goto repeat; /* XXX */
}
@@ -2530,7 +2538,7 @@
p->p_xsig = signo;
p->p_sigctx.ps_lwp = ksi.ksi_lid;
p->p_sigctx.ps_info = ksi.ksi_info;
- sigswitch(0, signo, true);
+ sigswitch(0, signo, false);
if (ktrpoint(KTR_PSIG)) {
if (p->p_emul->e_ktrpsig)
diff -r c3b047c6883b -r 406aa8798377 sys/sys/signalvar.h
--- a/sys/sys/signalvar.h Tue Oct 15 19:13:22 2019 +0000
+++ b/sys/sys/signalvar.h Tue Oct 15 19:23:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: signalvar.h,v 1.93.2.1 2019/10/15 18:32:13 martin Exp $ */
+/* $NetBSD: signalvar.h,v 1.93.2.2 2019/10/15 19:23:09 martin Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -137,7 +137,6 @@
int killpg1(struct lwp *, struct ksiginfo *, int, int);
void proc_unstop(struct proc *p);
void eventswitch(int, int, int);
-void sigswitch(int, int, bool);
int sigaction1(struct lwp *, int, const struct sigaction *,
Home |
Main Index |
Thread Index |
Old Index