Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Nov 2017 03:40:51 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326112 - head/sys/kern
Message-ID:  <201711230340.vAN3ep39064988@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Nov 23 03:40:51 2017
New Revision: 326112
URL: https://svnweb.freebsd.org/changeset/base/326112

Log:
  sx: unbreak debug after r326107
  
  An assertion was modified to use the found value, but it was not updated to
  handle a race where blocked threads appear after the entrance to the func.
  
  Move the assertion down to the area protected with sleepq lock where the
  lock is read anyway. This does not affect coverage of the assertion and
  is consistent with what rw locks are doing.
  
  Reported by:	Shawn Webb

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c	Thu Nov 23 03:20:12 2017	(r326111)
+++ head/sys/kern/kern_sx.c	Thu Nov 23 03:40:51 2017	(r326112)
@@ -828,12 +828,12 @@ _sx_xunlock_hard(struct sx *sx, uintptr_t x LOCK_FILE_
 	    atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
 		return;
 
-	MPASS(x & (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS));
 	if (LOCK_LOG_TEST(&sx->lock_object, 0))
 		CTR2(KTR_LOCK, "%s: %p contested", __func__, sx);
 
 	sleepq_lock(&sx->lock_object);
 	x = SX_READ_VALUE(sx);
+	MPASS(x & (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS));
 
 	/*
 	 * The wake up algorithm here is quite simple and probably not



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