diff --git a/sys/kern/kern_sleepq.c b/sys/kern/kern_sleepq.c index dda4eed3f1c0..e4bd395826b2 100644 --- a/sys/kern/kern_sleepq.c +++ b/sys/kern/kern_sleepq.c @@ -1,7 +1,7 @@ -/* $NetBSD: kern_sleepq.c,v 1.58 2020/01/12 13:08:32 ad Exp $ */ +/* $NetBSD: kern_sleepq.c,v 1.59 2020/01/26 19:01:56 ad Exp $ */ /*- - * Copyright (c) 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.58 2020/01/12 13:08:32 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.59 2020/01/26 19:01:56 ad Exp $"); #include #include @@ -114,7 +114,13 @@ sleepq_remove(sleepq_t *sq, lwp_t *l) KASSERT(lwp_locked(l, NULL)); - TAILQ_REMOVE(sq, l, l_sleepchain); + if ((l->l_syncobj->sobj_flag & SOBJ_SLEEPQ_NULL) == 0) { + KASSERT(sq != NULL); + TAILQ_REMOVE(sq, l, l_sleepchain); + } else { + KASSERT(sq == NULL); + } + l->l_syncobj = &sched_syncobj; l->l_wchan = NULL; l->l_sleepq = NULL; @@ -175,6 +181,12 @@ static void sleepq_insert(sleepq_t *sq, lwp_t *l, syncobj_t *sobj) { + if ((sobj->sobj_flag & SOBJ_SLEEPQ_NULL) != 0) { + KASSERT(sq == NULL); + return; + } + KASSERT(sq != NULL); + if ((sobj->sobj_flag & SOBJ_SLEEPQ_SORTED) != 0) { lwp_t *l2; const int pri = lwp_eprio(l); @@ -441,7 +453,7 @@ sleepq_reinsert(sleepq_t *sq, lwp_t *l) { KASSERT(l->l_sleepq == sq); - if ((l->l_syncobj->sobj_flag & SOBJ_SLEEPQ_SORTED) == 0) { + if ((l->l_syncobj->sobj_flag & SOBJ_SLEEPQ_SORTED) == 0) { return; } diff --git a/sys/sys/syncobj.h b/sys/sys/syncobj.h index df890cde94fe..458318875934 100644 --- a/sys/sys/syncobj.h +++ b/sys/sys/syncobj.h @@ -1,7 +1,7 @@ -/* $NetBSD: syncobj.h,v 1.8 2009/10/21 21:12:07 rmind Exp $ */ +/* $NetBSD: syncobj.h,v 1.9 2020/01/26 19:01:56 ad Exp $ */ /*- - * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2007, 2008, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -54,11 +54,13 @@ struct lwp *syncobj_noowner(wchan_t); #define SOBJ_SLEEPQ_SORTED 0x01 #define SOBJ_SLEEPQ_FIFO 0x02 #define SOBJ_SLEEPQ_LIFO 0x04 +#define SOBJ_SLEEPQ_NULL 0x08 extern syncobj_t sched_syncobj; extern syncobj_t mutex_syncobj; extern syncobj_t rw_syncobj; extern syncobj_t sleep_syncobj; +extern syncobj_t lwp_park_syncobj; #endif /* defined(_KERNEL) */