aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2017-03-28 15:31:49 -0700
committerBrian Behlendorf <[email protected]>2017-06-09 09:45:13 -0700
commit38240ebd7a35269e8ce74dc133b34120d707cd6f (patch)
tree73f3049cea30bbc878f33bc0af8c9b4ce02f9b15 /module
parentdbeb8796996b4a342f7de2b3eb4ea5b86ac260f9 (diff)
OpenZFS 8156 - dbuf_evict_notify() does not need dbuf_evict_lock
Authored by: Matthew Ahrens <[email protected]> Reviewed by: Dan Kimmel <[email protected]> Reviewed by: Paul Dagnelie <[email protected]> Approved by: Robert Mustacchi <[email protected]> Reviewed-by: George Melikov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Ported-by: Giuseppe Di Natale <[email protected]> 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. This commit results in a ~60% performance improvement for ARC-cached sequential reads. OpenZFS-issue: https://www.illumos.org/issues/8156 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f73e5d9 Closes #6204
Diffstat (limited to 'module')
-rw-r--r--module/zfs/dbuf.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c
index 611382686..70cc3108d 100644
--- a/module/zfs/dbuf.c
+++ b/module/zfs/dbuf.c
@@ -596,19 +596,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);
}
}