summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-04-18 20:59:05 +0000
committerjhb <jhb@FreeBSD.org>2003-04-18 20:59:05 +0000
commit801acfe1d4eb59bc3cb5449f681672d6712093a0 (patch)
tree42892c63b1dc99e6de1566799558fe413974fa5c /sys
parent85d7526d963b421bd1c63ee5609e74174c02bbed (diff)
downloadFreeBSD-src-801acfe1d4eb59bc3cb5449f681672d6712093a0.zip
FreeBSD-src-801acfe1d4eb59bc3cb5449f681672d6712093a0.tar.gz
- Make sigonstack() a regular function instead of an inline and add a proc
lock assertion to it. - SIGPENDING() no longer needs sched_lock, so only grab sched_lock to set the TDF_NEEDSIGCHK and TDF_ASTPENDING flags in signotify(). - Add a proc lock assertion to tdsigwakeup(). - Since we always set TDF_OLDMASK while holding the proc lock, the proc lock is sufficient protection to check its state in postsig() and we only need sched_lock when clearing the actual flag.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sig.c28
-rw-r--r--sys/sys/proc.h17
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 5329992..e6a6e17 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -208,10 +208,27 @@ signotify(struct thread *td)
SIGSETNAND(p->p_siglist, set);
SIGSETOR(td->td_siglist, set);
- mtx_lock_spin(&sched_lock);
- if (SIGPENDING(td))
+ if (SIGPENDING(td)) {
+ mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_NEEDSIGCHK | TDF_ASTPENDING;
- mtx_unlock_spin(&sched_lock);
+ mtx_unlock_spin(&sched_lock);
+ }
+}
+
+int
+sigonstack(size_t sp)
+{
+ struct proc *p = curthread->td_proc;
+
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ return ((p->p_flag & P_ALTSTACK) ?
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+ ((p->p_sigstk.ss_size == 0) ? (p->p_sigstk.ss_flags & SS_ONSTACK) :
+ ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size))
+#else
+ ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size)
+#endif
+ : 0);
}
static __inline int
@@ -1809,6 +1826,7 @@ tdsigwakeup(struct thread *td, int sig, sig_t action)
struct proc *p = td->td_proc;
register int prop;
+ PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_assert(&sched_lock, MA_OWNED);
prop = sigprop(sig);
/*
@@ -2144,13 +2162,13 @@ postsig(sig)
* mask from before the sigsuspend is what we want
* restored after the signal processing is completed.
*/
- mtx_lock_spin(&sched_lock);
if (td->td_flags & TDF_OLDMASK) {
returnmask = td->td_oldsigmask;
+ mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_OLDMASK;
+ mtx_unlock_spin(&sched_lock);
} else
returnmask = td->td_sigmask;
- mtx_unlock_spin(&sched_lock);
SIGSETOR(td->td_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
if (!SIGISMEMBER(ps->ps_signodefer, sig))
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index ffb570e..8c6fbcf 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -713,22 +713,6 @@ MALLOC_DECLARE(M_ZOMBIE);
#define FIRST_KSE_IN_KSEGRP(kg) TAILQ_FIRST(&kg->kg_kseq)
#define FIRST_KSE_IN_PROC(p) FIRST_KSE_IN_KSEGRP(FIRST_KSEGRP_IN_PROC(p))
-static __inline int
-sigonstack(size_t sp)
-{
- register struct thread *td = curthread;
- struct proc *p = td->td_proc;
-
- return ((p->p_flag & P_ALTSTACK) ?
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- ((p->p_sigstk.ss_size == 0) ? (p->p_sigstk.ss_flags & SS_ONSTACK) :
- ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size))
-#else
- ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size)
-#endif
- : 0);
-}
-
/*
* We use process IDs <= PID_MAX; PID_MAX + 1 must also fit in a pid_t,
* as it is used to represent "no process group".
@@ -892,6 +876,7 @@ int securelevel_gt(struct ucred *cr, int level);
void setrunnable(struct thread *);
void setrunqueue(struct thread *);
void setsugid(struct proc *p);
+int sigonstack(size_t sp);
void sleepinit(void);
void stopevent(struct proc *, u_int, u_int);
void cpu_idle(void);
OpenPOWER on IntegriCloud