diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-07-14 07:07:09 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-07-14 07:07:09 +0000 |
commit | 5d6e85ffab9430df8939f878e5cbf5ae3e007b9d (patch) | |
tree | b432d8e0dbd88455abb56265c4c90fd952983f65 /sys/kern | |
parent | 8f73de71fe40d634e210069613ce1ff1d2564eef (diff) |
struct sleep_state is no longer used, remove it.
Also remove the priority argument to sleep_finish() the code can use
the p_flag P_SINTR flag to know if the signal check is needed or not.
OK cheloha@ kettenis@ mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_rwlock.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_sched.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 34 | ||||
-rw-r--r-- | sys/kern/kern_timeout.c | 7 | ||||
-rw-r--r-- | sys/kern/subr_log.c | 8 |
6 files changed, 29 insertions, 41 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 17e00fedaa3..4e3ac524808 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.49 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.50 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org> @@ -224,7 +224,6 @@ int rw_enter(struct rwlock *rwl, int flags) { const struct rwlock_op *op; - struct sleep_state sls; unsigned long inc, o; #ifdef MULTIPROCESSOR /* @@ -279,11 +278,11 @@ retry: prio = op->wait_prio; if (flags & RW_INTR) prio |= PCATCH; - sleep_setup(&sls, rwl, prio, rwl->rwl_name); + sleep_setup(rwl, prio, rwl->rwl_name); do_sleep = !rw_cas(&rwl->rwl_owner, o, set); - error = sleep_finish(&sls, prio, 0, do_sleep); + error = sleep_finish(0, do_sleep); if ((flags & RW_INTR) && (error != 0)) return (error); diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 7fae2f8df33..f4ac3817711 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.78 2023/07/11 07:02:43 claudio Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.79 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org> * @@ -669,13 +669,12 @@ sched_stop_secondary_cpus(void) } CPU_INFO_FOREACH(cii, ci) { struct schedstate_percpu *spc = &ci->ci_schedstate; - struct sleep_state sls; if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci)) continue; while ((spc->spc_schedflags & SPCF_HALTED) == 0) { - sleep_setup(&sls, spc, PZERO, "schedstate"); - sleep_finish(&sls, PZERO, 0, + sleep_setup(spc, PZERO, "schedstate"); + sleep_finish(0, (spc->spc_schedflags & SPCF_HALTED) == 0); } } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index d46b229acc9..fba5f72d8bf 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.309 2023/07/11 07:02:43 claudio Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.310 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -2164,15 +2164,14 @@ single_thread_set(struct proc *p, enum single_thread_mode mode, int wait) int single_thread_wait(struct process *pr, int recheck) { - struct sleep_state sls; int wait; /* wait until they're all suspended */ wait = pr->ps_singlecount > 0; while (wait) { - sleep_setup(&sls, &pr->ps_singlecount, PWAIT, "suspend"); + sleep_setup(&pr->ps_singlecount, PWAIT, "suspend"); wait = pr->ps_singlecount > 0; - sleep_finish(&sls, PWAIT, 0, wait); + sleep_finish(0, wait); if (!recheck) break; } diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index c856ab7903d..d4087b5fcce 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.194 2023/07/11 07:02:43 claudio Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.195 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -115,7 +115,6 @@ extern int safepri; int tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) { - struct sleep_state sls; #ifdef MULTIPROCESSOR int hold_count; #endif @@ -151,8 +150,8 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) return (0); } - sleep_setup(&sls, ident, priority, wmesg); - return sleep_finish(&sls, priority, timo, 1); + sleep_setup(ident, priority, wmesg); + return sleep_finish(timo, 1); } int @@ -206,7 +205,6 @@ int msleep(const volatile void *ident, struct mutex *mtx, int priority, const char *wmesg, int timo) { - struct sleep_state sls; int error, spl; #ifdef MULTIPROCESSOR int hold_count; @@ -244,11 +242,11 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority, return (0); } - sleep_setup(&sls, ident, priority, wmesg); + sleep_setup(ident, priority, wmesg); mtx_leave(mtx); /* signal may stop the process, release mutex before that */ - error = sleep_finish(&sls, priority, timo, 1); + error = sleep_finish(timo, 1); if ((priority & PNORELOCK) == 0) mtx_enter(mtx); @@ -287,7 +285,6 @@ int rwsleep(const volatile void *ident, struct rwlock *rwl, int priority, const char *wmesg, int timo) { - struct sleep_state sls; int error, status; KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); @@ -296,11 +293,11 @@ rwsleep(const volatile void *ident, struct rwlock *rwl, int priority, rw_assert_anylock(rwl); status = rw_status(rwl); - sleep_setup(&sls, ident, priority, wmesg); + sleep_setup(ident, priority, wmesg); rw_exit(rwl); /* signal may stop the process, release rwlock before that */ - error = sleep_finish(&sls, priority, timo, 1); + error = sleep_finish(timo, 1); if ((priority & PNORELOCK) == 0) rw_enter(rwl, status); @@ -332,8 +329,7 @@ rwsleep_nsec(const volatile void *ident, struct rwlock *rwl, int priority, } void -sleep_setup(struct sleep_state *sls, const volatile void *ident, int prio, - const char *wmesg) +sleep_setup(const volatile void *ident, int prio, const char *wmesg) { struct proc *p = curproc; int s; @@ -365,12 +361,12 @@ sleep_setup(struct sleep_state *sls, const volatile void *ident, int prio, } int -sleep_finish(struct sleep_state *sls, int prio, int timo, int do_sleep) +sleep_finish(int timo, int do_sleep) { struct proc *p = curproc; int s, catch, error = 0, error1 = 0; - catch = prio & PCATCH; + catch = p->p_flag & P_SINTR; if (timo != 0) { KASSERT((p->p_flag & P_TIMEOUT) == 0); @@ -825,7 +821,6 @@ refcnt_rele_wake(struct refcnt *r) void refcnt_finalize(struct refcnt *r, const char *wmesg) { - struct sleep_state sls; u_int refs; membar_exit_before_atomic(); @@ -833,9 +828,9 @@ refcnt_finalize(struct refcnt *r, const char *wmesg) KASSERT(refs != ~0); TRACEINDEX(refcnt, r->r_traceidx, r, refs + 1, -1); while (refs) { - sleep_setup(&sls, r, PWAIT, wmesg); + sleep_setup(r, PWAIT, wmesg); refs = atomic_load_int(&r->r_refs); - sleep_finish(&sls, PWAIT, 0, refs); + sleep_finish(0, refs); } TRACEINDEX(refcnt, r->r_traceidx, r, refs, 0); /* Order subsequent loads and stores after refs == 0 load. */ @@ -879,13 +874,12 @@ cond_signal(struct cond *c) void cond_wait(struct cond *c, const char *wmesg) { - struct sleep_state sls; unsigned int wait; wait = atomic_load_int(&c->c_wait); while (wait) { - sleep_setup(&sls, c, PWAIT, wmesg); + sleep_setup(c, PWAIT, wmesg); wait = atomic_load_int(&c->c_wait); - sleep_finish(&sls, PWAIT, 0, wait); + sleep_finish(0, wait); } } diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index b20616e7e3d..4ca81ad42df 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.93 2023/07/06 23:24:37 cheloha Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.94 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org> * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> @@ -735,7 +735,6 @@ softclock_thread(void *arg) { CPU_INFO_ITERATOR cii; struct cpu_info *ci; - struct sleep_state sls; struct timeout *to; int s; @@ -751,8 +750,8 @@ softclock_thread(void *arg) s = splsoftclock(); for (;;) { - sleep_setup(&sls, &timeout_proc, PSWP, "bored"); - sleep_finish(&sls, PSWP, 0, CIRCQ_EMPTY(&timeout_proc)); + sleep_setup(&timeout_proc, PSWP, "bored"); + sleep_finish(0, CIRCQ_EMPTY(&timeout_proc)); mtx_enter(&timeout_mutex); while (!CIRCQ_EMPTY(&timeout_proc)) { diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 1f4ae515bfa..12bd44e7ca3 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.76 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: subr_log.c,v 1.77 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -233,7 +233,6 @@ logclose(dev_t dev, int flag, int mode, struct proc *p) int logread(dev_t dev, struct uio *uio, int flag) { - struct sleep_state sls; struct msgbuf *mbp = msgbufp; size_t l, rpos; int error = 0; @@ -250,9 +249,8 @@ logread(dev_t dev, struct uio *uio, int flag) * Set up and enter sleep manually instead of using msleep() * to keep log_mtx as a leaf lock. */ - sleep_setup(&sls, mbp, LOG_RDPRI | PCATCH, "klog"); - error = sleep_finish(&sls, LOG_RDPRI | PCATCH, 0, - logsoftc.sc_state & LOG_RDWAIT); + sleep_setup(mbp, LOG_RDPRI | PCATCH, "klog"); + error = sleep_finish(0, logsoftc.sc_state & LOG_RDWAIT); mtx_enter(&log_mtx); if (error) goto out; |