Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Sep 2019 06:38:34 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r352890 - stable/12/sys/kern
Message-ID:  <201909300638.x8U6cYS9079252@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Sep 30 06:38:34 2019
New Revision: 352890
URL: https://svnweb.freebsd.org/changeset/base/352890

Log:
  MFC r351417: r351417: INVARIANTS: treat LA_LOCKED as the same of LA_XLOCKED
  in mtx_assert.

Modified:
  stable/12/sys/kern/kern_mutex.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_mutex.c
==============================================================================
--- stable/12/sys/kern/kern_mutex.c	Mon Sep 30 06:09:32 2019	(r352889)
+++ stable/12/sys/kern/kern_mutex.c	Mon Sep 30 06:38:34 2019	(r352890)
@@ -176,6 +176,21 @@ void
 assert_mtx(const struct lock_object *lock, int what)
 {
 
+	/*
+	 * Treat LA_LOCKED as if LA_XLOCKED was asserted.
+	 *
+	 * Some callers of lc_assert uses LA_LOCKED to indicate that either
+	 * a shared lock or write lock was held, while other callers uses
+	 * the more strict LA_XLOCKED (used as MA_OWNED).
+	 *
+	 * Mutex is the only lock class that can not be shared, as a result,
+	 * we can reasonably consider the caller really intends to assert
+	 * LA_XLOCKED when they are asserting LA_LOCKED on a mutex object.
+	 */
+	if (what & LA_LOCKED) {
+		what &= ~LA_LOCKED;
+		what |= LA_XLOCKED;
+	}
 	mtx_assert((const struct mtx *)lock, what);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909300638.x8U6cYS9079252>