Sun Apr 9 12:16:42 2023 UTC ()
kpause(9): Simplify assertion.  No functional change intended.


(riastradh)
diff -r1.353 -r1.354 src/sys/kern/kern_synch.c

cvs diff -r1.353 -r1.354 src/sys/kern/kern_synch.c (expand / switch to unified diff)

--- src/sys/kern/kern_synch.c 2022/12/05 15:47:14 1.353
+++ src/sys/kern/kern_synch.c 2023/04/09 12:16:42 1.354
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_synch.c,v 1.353 2022/12/05 15:47:14 martin Exp $ */ 1/* $NetBSD: kern_synch.c,v 1.354 2023/04/09 12:16:42 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020 4 * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020
5 * The NetBSD Foundation, Inc. 5 * The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10 * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and 10 * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and
11 * Daniel Sieger. 11 * Daniel Sieger.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -59,27 +59,27 @@ @@ -59,27 +59,27 @@
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * SUCH DAMAGE. 66 * SUCH DAMAGE.
67 * 67 *
68 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 68 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
69 */ 69 */
70 70
71#include <sys/cdefs.h> 71#include <sys/cdefs.h>
72__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.353 2022/12/05 15:47:14 martin Exp $"); 72__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.354 2023/04/09 12:16:42 riastradh Exp $");
73 73
74#include "opt_kstack.h" 74#include "opt_kstack.h"
75#include "opt_dtrace.h" 75#include "opt_dtrace.h"
76 76
77#define __MUTEX_PRIVATE 77#define __MUTEX_PRIVATE
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/systm.h> 80#include <sys/systm.h>
81#include <sys/proc.h> 81#include <sys/proc.h>
82#include <sys/kernel.h> 82#include <sys/kernel.h>
83#include <sys/cpu.h> 83#include <sys/cpu.h>
84#include <sys/pserialize.h> 84#include <sys/pserialize.h>
85#include <sys/resource.h> 85#include <sys/resource.h>
@@ -223,27 +223,27 @@ mtsleep(wchan_t ident, pri_t priority, c @@ -223,27 +223,27 @@ mtsleep(wchan_t ident, pri_t priority, c
223 223
224 return error; 224 return error;
225} 225}
226 226
227/* 227/*
228 * General sleep call for situations where a wake-up is not expected. 228 * General sleep call for situations where a wake-up is not expected.
229 */ 229 */
230int 230int
231kpause(const char *wmesg, bool intr, int timo, kmutex_t *mtx) 231kpause(const char *wmesg, bool intr, int timo, kmutex_t *mtx)
232{ 232{
233 struct lwp *l = curlwp; 233 struct lwp *l = curlwp;
234 int error; 234 int error;
235 235
236 KASSERT(!(timo == 0 && intr == false)); 236 KASSERT(timo != 0 || intr);
237 237
238 if (sleepq_dontsleep(l)) 238 if (sleepq_dontsleep(l))
239 return sleepq_abort(NULL, 0); 239 return sleepq_abort(NULL, 0);
240 240
241 if (mtx != NULL) 241 if (mtx != NULL)
242 mutex_exit(mtx); 242 mutex_exit(mtx);
243 l->l_kpriority = true; 243 l->l_kpriority = true;
244 lwp_lock(l); 244 lwp_lock(l);
245 KERNEL_UNLOCK_ALL(NULL, &l->l_biglocks); 245 KERNEL_UNLOCK_ALL(NULL, &l->l_biglocks);
246 sleepq_enqueue(NULL, l, wmesg, &kpause_syncobj, intr); 246 sleepq_enqueue(NULL, l, wmesg, &kpause_syncobj, intr);
247 error = sleepq_block(timo, intr, &kpause_syncobj); 247 error = sleepq_block(timo, intr, &kpause_syncobj);
248 if (mtx != NULL) 248 if (mtx != NULL)
249 mutex_enter(mtx); 249 mutex_enter(mtx);