Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jun 2017 15:28:57 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319750 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201706091528.v59FSvVw041364@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Fri Jun  9 15:28:57 2017
New Revision: 319750
URL: https://svnweb.freebsd.org/changeset/base/319750

Log:
  MFV r319741: 8156 dbuf_evict_notify() does not need dbuf_evict_lock
  
  illumos/illumos-gate@dbfd9f930004c390a2ce2cf850c71b4f880eef9c
  https://github.com/illumos/illumos-gate/commit/dbfd9f930004c390a2ce2cf850c71b4f880eef9c
  
  https://www.illumos.org/issues/8156
    dbuf_evict_notify() holds the dbuf_evict_lock while checking if it should do
    the eviction itself (because the evict thread is not able to keep up).
    This can result in massive lock contention.
    It isn't necessary to hold the lock, because if we make the wrong choice
    occasionally, nothing bad will happen.
  
  Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
  Reviewed by: Paul Dagnelie <pcd@delphix.com>
  Approved by: Robert Mustacchi <rm@joyent.com>
  Author: Matthew Ahrens <mahrens@delphix.com>
  MFC after:	1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c	Fri Jun  9 15:27:22 2017	(r319749)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c	Fri Jun  9 15:28:57 2017	(r319750)
@@ -560,19 +560,15 @@ dbuf_evict_notify(void)
 	if (tsd_get(zfs_dbuf_evict_key) != NULL)
 		return;
 
+	/*
+	 * We check if we should evict without holding the dbuf_evict_lock,
+	 * because it's OK to occasionally make the wrong decision here,
+	 * and grabbing the lock results in massive lock contention.
+	 */
 	if (refcount_count(&dbuf_cache_size) > dbuf_cache_max_bytes) {
-		boolean_t evict_now = B_FALSE;
-
-		mutex_enter(&dbuf_evict_lock);
-		if (refcount_count(&dbuf_cache_size) > dbuf_cache_max_bytes) {
-			evict_now = dbuf_cache_above_hiwater();
-			cv_signal(&dbuf_evict_cv);
-		}
-		mutex_exit(&dbuf_evict_lock);
-
-		if (evict_now) {
+		if (dbuf_cache_above_hiwater())
 			dbuf_evict_one();
-		}
+		cv_signal(&dbuf_evict_cv);
 	}
 }
 



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