Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Aug 2019 18:01:47 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350540 - head/sys/kern
Message-ID:  <201908021801.x72I1lLA023737@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Fri Aug  2 18:01:47 2019
New Revision: 350540
URL: https://svnweb.freebsd.org/changeset/base/350540

Log:
  Only check the blessings table for known LORs.
  
  Previously we would check for blessings before marking a given lock
  pair as reversed, so each "reversed" lock acquisition would require
  a linear scan of the table.  Instead, check the table after marking
  the pair as reversed but before generating a report.
  
  Reviewed by:	jhb
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21135

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c	Fri Aug  2 16:05:36 2019	(r350539)
+++ head/sys/kern/subr_witness.c	Fri Aug  2 18:01:47 2019	(r350540)
@@ -1344,14 +1344,6 @@ witness_checkorder(struct lock_object *lock, int flags
 			 * is allowed or has already been yelled about.
 			 */
 
-			/*
-			 * If the lock order is blessed, just bail.  We don't
-			 * look for other lock order violations though, which
-			 * may be a bug.
-			 */
-			if (blessed(w, w1))
-				goto out;
-
 			/* Bail if this violation is known */
 			if (w_rmatrix[w1->w_index][w->w_index] & WITNESS_REVERSAL)
 				goto out;
@@ -1361,6 +1353,14 @@ witness_checkorder(struct lock_object *lock, int flags
 			w_rmatrix[w->w_index][w1->w_index] |= WITNESS_REVERSAL;
 			w->w_reversed = w1->w_reversed = 1;
 			witness_increment_graph_generation();
+
+			/*
+			 * If the lock order is blessed, bail before logging
+			 * anything.  We don't look for other lock order
+			 * violations though, which may be a bug.
+			 */
+			if (blessed(w, w1))
+				goto out;
 			mtx_unlock_spin(&w_mtx);
 
 #ifdef WITNESS_NO_VNODE
@@ -2650,6 +2650,9 @@ restart:
 				    &tmp_data2->wlod_stack);
 			}
 			mtx_unlock_spin(&w_mtx);
+
+			if (blessed(tmp_w1, tmp_w2))
+				continue;
 
 			sbuf_printf(sb,
 	    "\nLock order reversal between \"%s\"(%s) and \"%s\"(%s)!\n",



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