svn commit: r355416 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Thu Dec 5 13:43:45 UTC 2019
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
More information about the svn-src-all
mailing list