-/* $OpenBSD: dt_dev.c,v 1.27 2023/06/28 08:23:25 claudio Exp $ */
+/* $OpenBSD: dt_dev.c,v 1.28 2023/07/14 07:07:08 claudio Exp $ */
/*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
int
dtread(dev_t dev, struct uio *uio, int flags)
{
- struct sleep_state sls;
struct dt_softc *sc;
struct dt_evt *estq;
struct dt_pcb *dp;
return (EMSGSIZE);
while (!sc->ds_evtcnt) {
- sleep_setup(&sls, sc, PWAIT | PCATCH, "dtread");
- error = sleep_finish(&sls, PWAIT | PCATCH, 0, !sc->ds_evtcnt);
+ sleep_setup(sc, PWAIT | PCATCH, "dtread");
+ error = sleep_finish(0, !sc->ds_evtcnt);
if (error == EINTR || error == ERESTART)
break;
}
-/* $OpenBSD: drm_linux.c,v 1.99 2023/06/28 08:23:25 claudio Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.100 2023/07/14 07:07:08 claudio Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
long
schedule_timeout(long timeout)
{
- struct sleep_state sls;
unsigned long deadline;
int wait, spl, prio, timo = 0;
if (timeout != MAX_SCHEDULE_TIMEOUT)
timo = timeout;
prio = sch_priority;
- sleep_setup(&sls, sch_ident, prio, "schto");
+ sleep_setup(sch_ident, prio, "schto");
wait = (sch_proc == curproc && timeout > 0);
if (timeout != MAX_SCHEDULE_TIMEOUT)
deadline = jiffies + timeout;
- sleep_finish(&sls, prio, timo, wait);
+ sleep_finish(timo, wait);
if (timeout != MAX_SCHEDULE_TIMEOUT)
timeout = deadline - jiffies;
-/* $OpenBSD: if_myx.c,v 1.117 2023/06/28 08:23:25 claudio Exp $ */
+/* $OpenBSD: if_myx.c,v 1.118 2023/07/14 07:07:08 claudio Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org>
struct ifnet *ifp = &sc->sc_ac.ac_if;
volatile struct myx_status *sts = sc->sc_sts;
bus_dmamap_t map = sc->sc_sts_dma.mxm_map;
- struct sleep_state sls;
struct myx_cmd mc;
int s;
int ring;
(void)myx_cmd(sc, MYXCMD_SET_IFDOWN, &mc, NULL);
while (sc->sc_state != MYX_S_OFF) {
- sleep_setup(&sls, sts, PWAIT, "myxdown");
+ sleep_setup(sts, PWAIT, "myxdown");
membar_consumer();
- sleep_finish(&sls, PWAIT, 0, sc->sc_state != MYX_S_OFF);
+ sleep_finish(0, sc->sc_state != MYX_S_OFF);
}
s = splnet();
-/* $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>
rw_enter(struct rwlock *rwl, int flags)
{
const struct rwlock_op *op;
- struct sleep_state sls;
unsigned long inc, o;
#ifdef MULTIPROCESSOR
/*
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);
-/* $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>
*
}
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);
}
}
-/* $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 $ */
/*
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;
}
-/* $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 $ */
/*
int
tsleep(const volatile void *ident, int priority, const char *wmesg, int timo)
{
- struct sleep_state sls;
#ifdef MULTIPROCESSOR
int hold_count;
#endif
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
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;
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);
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);
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);
}
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;
}
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);
void
refcnt_finalize(struct refcnt *r, const char *wmesg)
{
- struct sleep_state sls;
u_int refs;
membar_exit_before_atomic();
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. */
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);
}
}
-/* $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>
{
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
- struct sleep_state sls;
struct timeout *to;
int s;
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)) {
-/* $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 $ */
/*
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;
* 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;
-/* $OpenBSD: proc.h,v 1.345 2023/07/11 07:02:43 claudio Exp $ */
+/* $OpenBSD: proc.h,v 1.346 2023/07/14 07:07:08 claudio Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
int proc_cansugid(struct proc *);
-struct sleep_state {
- int sls_s;
-};
-
struct cond {
unsigned int c_wait; /* [a] initialized and waiting */
};
-/* $OpenBSD: systm.h,v 1.162 2023/06/28 08:23:25 claudio Exp $ */
+/* $OpenBSD: systm.h,v 1.163 2023/07/14 07:07:08 claudio Exp $ */
/* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */
/*-
void start_periodic_resettodr(void);
void stop_periodic_resettodr(void);
-struct sleep_state;
-void sleep_setup(struct sleep_state *, const volatile void *, int,
- const char *);
-int sleep_finish(struct sleep_state *, int, int, int);
+void sleep_setup(const volatile void *, int, const char *);
+int sleep_finish(int, int);
void sleep_queue_init(void);
struct cond;