On Wed, Dec 23, 2020 at 02:42:18PM -0700, Theo de Raadt wrote: > I agree. This chunk below is really gross and does not follow the > special wakeup channel metaphor. > > It is *entirely clear* that a &channel called "nowake" has no wakeup. > Like duh. > > > +/* > > + * nowake is a global sleep channel for threads that do not want > > + * to receive wakeup(9) broadcasts. > > + */ > > +int __nowake; > > +void *nowake = &__nowake;
So we'll go with this? Index: kern/kern_synch.c =================================================================== RCS file: /cvs/src/sys/kern/kern_synch.c,v retrieving revision 1.172 diff -u -p -r1.172 kern_synch.c --- kern/kern_synch.c 7 Dec 2020 16:55:29 -0000 1.172 +++ kern/kern_synch.c 23 Dec 2020 23:03:31 -0000 @@ -87,6 +87,11 @@ sleep_queue_init(void) TAILQ_INIT(&slpque[i]); } +/* + * Global sleep channel for threads that do not want to + * receive wakeup(9) broadcasts. + */ +int nowake; /* * During autoconfiguration or after a panic, a sleep will simply @@ -119,6 +124,7 @@ tsleep(const volatile void *ident, int p #endif KASSERT((priority & ~(PRIMASK | PCATCH)) == 0); + KASSERT(ident != nowake || ISSET(priority, PCATCH) || timo != 0); #ifdef MULTIPROCESSOR KASSERT(timo || _kernel_lock_held()); @@ -213,6 +219,7 @@ msleep(const volatile void *ident, struc #endif KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); + KASSERT(ident != nowake || ISSET(priority, PCATCH) || timo != 0); KASSERT(mtx != NULL); if (priority & PCATCH) @@ -301,6 +308,7 @@ rwsleep(const volatile void *ident, stru int error, status; KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); + KASSERT(ident != nowake || ISSET(priority, PCATCH) || timo != 0); rw_assert_anylock(rwl); status = rw_status(rwl); Index: sys/systm.h =================================================================== RCS file: /cvs/src/sys/sys/systm.h,v retrieving revision 1.148 diff -u -p -r1.148 systm.h --- sys/systm.h 26 Aug 2020 03:29:07 -0000 1.148 +++ sys/systm.h 23 Dec 2020 23:03:31 -0000 @@ -107,6 +107,8 @@ extern struct vnode *rootvp; /* vnode eq extern dev_t swapdev; /* swapping device */ extern struct vnode *swapdev_vp;/* vnode equivalent to above */ +extern int nowake; /* dead wakeup(9) channel */ + struct proc; struct process; #define curproc curcpu()->ci_curproc