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",
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to