Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Dec 2019 13:43:45 +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: r355416 - head/sys/kern
Message-ID:  <201912051343.xB5Dhj4G090822@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Dec  5 13:43:44 2019
New Revision: 355416
URL: https://svnweb.freebsd.org/changeset/base/355416

Log:
  sx: check for SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER when exclusive-locking
  
  First, this removes a spurious difference compared to rw locks.
  More importantly though this avoids a trip through sleepq code if the lock
  happens to be caught in this state.

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c	Thu Dec  5 13:41:22 2019	(r355415)
+++ head/sys/kern/kern_sx.c	Thu Dec  5 13:43:44 2019	(r355416)
@@ -661,6 +661,12 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO
 		lda.spin_cnt++;
 #endif
 #ifdef ADAPTIVE_SX
+		if (x == (SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER)) {
+			if (atomic_fcmpset_acq_ptr(&sx->sx_lock, &x, tid))
+				break;
+			continue;
+		}
+
 		/*
 		 * If the lock is write locked and the owner is
 		 * running on another CPU, spin until the owner stops



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