Sun Mar 8 00:26:06 2020 UTC ()
split an "a && b" assertion into two so it's clear in the dump which condition
was not true even if both are true by the time the dump is written.


(chs)
diff -r1.89 -r1.90 src/sys/kern/kern_mutex.c

cvs diff -r1.89 -r1.90 src/sys/kern/kern_mutex.c (expand / switch to unified diff)

--- src/sys/kern/kern_mutex.c 2020/01/23 12:35:23 1.89
+++ src/sys/kern/kern_mutex.c 2020/03/08 00:26:06 1.90
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_mutex.c,v 1.89 2020/01/23 12:35:23 ad Exp $ */ 1/* $NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Andrew Doran. 8 * by Jason R. Thorpe and Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 */ 30 */
31 31
32/* 32/*
33 * Kernel mutex implementation, modeled after those found in Solaris, 33 * Kernel mutex implementation, modeled after those found in Solaris,
34 * a description of which can be found in: 34 * a description of which can be found in:
35 * 35 *
36 * Solaris Internals: Core Kernel Architecture, Jim Mauro and 36 * Solaris Internals: Core Kernel Architecture, Jim Mauro and
37 * Richard McDougall. 37 * Richard McDougall.
38 */ 38 */
39 39
40#define __MUTEX_PRIVATE 40#define __MUTEX_PRIVATE
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.89 2020/01/23 12:35:23 ad Exp $"); 43__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.90 2020/03/08 00:26:06 chs Exp $");
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/atomic.h> 46#include <sys/atomic.h>
47#include <sys/proc.h> 47#include <sys/proc.h>
48#include <sys/mutex.h> 48#include <sys/mutex.h>
49#include <sys/sched.h> 49#include <sys/sched.h>
50#include <sys/sleepq.h> 50#include <sys/sleepq.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/lockdebug.h> 52#include <sys/lockdebug.h>
53#include <sys/kernel.h> 53#include <sys/kernel.h>
54#include <sys/intr.h> 54#include <sys/intr.h>
55#include <sys/lock.h> 55#include <sys/lock.h>
56#include <sys/types.h> 56#include <sys/types.h>
@@ -374,28 +374,28 @@ mutex_init(kmutex_t *mtx, kmutex_type_t  @@ -374,28 +374,28 @@ mutex_init(kmutex_t *mtx, kmutex_type_t
374} 374}
375 375
376/* 376/*
377 * mutex_destroy: 377 * mutex_destroy:
378 * 378 *
379 * Tear down a mutex. 379 * Tear down a mutex.
380 */ 380 */
381void 381void
382mutex_destroy(kmutex_t *mtx) 382mutex_destroy(kmutex_t *mtx)
383{ 383{
384 uintptr_t owner = mtx->mtx_owner; 384 uintptr_t owner = mtx->mtx_owner;
385 385
386 if (MUTEX_ADAPTIVE_P(owner)) { 386 if (MUTEX_ADAPTIVE_P(owner)) {
387 MUTEX_ASSERT(mtx, !MUTEX_OWNED(owner) && 387 MUTEX_ASSERT(mtx, !MUTEX_OWNED(owner));
388 !MUTEX_HAS_WAITERS(mtx)); 388 MUTEX_ASSERT(mtx, !MUTEX_HAS_WAITERS(mtx));
389 } else { 389 } else {
390 MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx)); 390 MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx));
391 } 391 }
392 392
393 LOCKDEBUG_FREE(MUTEX_DEBUG_P(mtx), mtx); 393 LOCKDEBUG_FREE(MUTEX_DEBUG_P(mtx), mtx);
394 MUTEX_DESTROY(mtx); 394 MUTEX_DESTROY(mtx);
395} 395}
396 396
397#ifdef MULTIPROCESSOR 397#ifdef MULTIPROCESSOR
398/* 398/*
399 * mutex_oncpu: 399 * mutex_oncpu:
400 * 400 *
401 * Return true if an adaptive mutex owner is running on a CPU in the 401 * Return true if an adaptive mutex owner is running on a CPU in the