summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
committerbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
commitf364d4ac3621ae2689a3cc1b82c73eb491475a24 (patch)
tree84444d0341ce519800ed7913d826f5f38c622d6d /sys/kern/kern_sig.c
parent363bdddf694863339f6629340cfb324771b8ffe7 (diff)
downloadFreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.zip
FreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.tar.gz
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index a72de0e..deee375 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -186,9 +186,9 @@ CURSIG(struct proc *p)
SIGSETNAND(tmpset, p->p_sigmask);
if (SIGISEMPTY(tmpset) && (p->p_flag & P_TRACED) == 0)
return (0);
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
r = issignal(p);
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
return (r);
}
@@ -1087,11 +1087,11 @@ psignal(p, sig)
action = SIG_DFL;
}
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
if (p->p_nice > NZERO && action == SIG_DFL && (prop & SA_KILL) &&
(p->p_flag & P_TRACED) == 0)
p->p_nice = NZERO;
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
if (prop & SA_CONT)
SIG_STOPSIGMASK(p->p_siglist);
@@ -1116,9 +1116,9 @@ psignal(p, sig)
* Defer further processing for signals which are held,
* except that stopped processes must be continued by SIGCONT.
*/
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
if (action == SIG_HOLD && (!(prop & SA_CONT) || p->p_stat != SSTOP)) {
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(p);
return;
}
@@ -1132,7 +1132,7 @@ psignal(p, sig)
* trap() or syscall().
*/
if ((p->p_sflag & PS_SINTR) == 0) {
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
goto out;
}
/*
@@ -1142,7 +1142,7 @@ psignal(p, sig)
*/
if (p->p_flag & P_TRACED)
goto run;
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
/*
* If SIGCONT is default (or ignored) and process is
* asleep, we are finished; the process should not
@@ -1182,7 +1182,7 @@ psignal(p, sig)
/* NOTREACHED */
case SSTOP:
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
/*
* If traced process is already stopped,
* then no further action is necessary.
@@ -1211,11 +1211,11 @@ psignal(p, sig)
SIGDELSET(p->p_siglist, sig);
if (action == SIG_CATCH)
goto runfast;
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
if (p->p_wchan == NULL)
goto run;
p->p_stat = SSLEEP;
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
goto out;
}
@@ -1234,14 +1234,14 @@ psignal(p, sig)
* runnable and can look at the signal. But don't make
* the process runnable, leave it stopped.
*/
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
if (p->p_wchan && p->p_sflag & PS_SINTR) {
if (p->p_sflag & PS_CVWAITQ)
cv_waitq_remove(p);
else
unsleep(p);
}
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
goto out;
default:
@@ -1251,17 +1251,17 @@ psignal(p, sig)
* It will either never be noticed, or noticed very soon.
*/
if (p == curproc) {
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
signotify(p);
}
#ifdef SMP
else if (p->p_stat == SRUN) {
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
forward_signal(p);
}
#endif
else
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
goto out;
}
/*NOTREACHED*/
@@ -1270,14 +1270,14 @@ runfast:
/*
* Raise priority to at least PUSER.
*/
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
if (p->p_priority > PUSER)
p->p_priority = PUSER;
run:
/* If we jump here, sched_lock has to be owned. */
mtx_assert(&sched_lock, MA_OWNED | MA_NOTRECURSED);
setrunnable(p);
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
out:
/* If we jump here, sched_lock should not be owned. */
mtx_assert(&sched_lock, MA_NOTOWNED);
@@ -1336,10 +1336,10 @@ issignal(p)
do {
stop(p);
PROCTREE_LOCK(PT_RELEASE);
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
DROP_GIANT_NOSWITCH();
mi_switch();
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROCTREE_LOCK(PT_SHARED);
} while (!trace_req(p)
@@ -1413,10 +1413,10 @@ issignal(p)
if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
PROCTREE_LOCK(PT_RELEASE);
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
DROP_GIANT_NOSWITCH();
mi_switch();
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
break;
} else if (prop & SA_IGNORE) {
@@ -1464,11 +1464,11 @@ stop(p)
{
PROCTREE_ASSERT(PT_SHARED);
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
p->p_stat = SSTOP;
p->p_flag &= ~P_WAITED;
wakeup((caddr_t)p->p_pptr);
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
}
/*
OpenPOWER on IntegriCloud