Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Mar 2018 21:26:27 +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: r330294 - head/sys/kern
Message-ID:  <201803022126.w22LQRKH034839@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Fri Mar  2 21:26:27 2018
New Revision: 330294
URL: https://svnweb.freebsd.org/changeset/base/330294

Log:
  sx: fix adaptive spinning broken in r327397
  
  The condition was flipped.
  
  In particular heavy multithreaded kernel builds on zfs started suffering
  due to nested sx locks.
  
  For instance make -s -j 128 buildkernel:
  
  before: 3326.67s user 1269.62s system 6981% cpu 1:05.84 total
  after: 3365.55s user 911.27s system 6871% cpu 1:02.24 total
  
  ps.
        .-'---`-.			      .-'---`-.
      ,'          `.		    ,'          `.
      |             \		    |             \
      |              \		    |              \
      \           _  \		    \           _  \
      ,\  _    ,'-,/-)\		    ,\  _    ,'-,/-)\
      ( * \ \,' ,' ,'-)		    ( * \ \,' ,' ,'-)
       `._,)     -',-')		     `._,)     -',-')
         \/         ''/		       \/         ''/
          )        / /		        )        / /
         /       ,'-'		       /       ,'-'

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c	Fri Mar  2 20:59:36 2018	(r330293)
+++ head/sys/kern/kern_sx.c	Fri Mar  2 21:26:27 2018	(r330294)
@@ -584,7 +584,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO
 		    sx->lock_object.lo_name, (void *)sx->sx_lock, file, line);
 
 #ifdef ADAPTIVE_SX
-	adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) != 0);
+	adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0);
 #endif
 
 #ifdef HWPMC_HOOKS
@@ -937,7 +937,7 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LO
 #endif
 
 #ifdef ADAPTIVE_SX
-	adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) != 0);
+	adaptive = ((sx->lock_object.lo_flags & SX_NOADAPTIVE) == 0);
 #endif
 
 #ifdef HWPMC_HOOKS



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