mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
OpenZFS 8156 - dbuf_evict_notify() does not need dbuf_evict_lock
Authored by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Paul Dagnelie <pcd@delphix.com> Approved by: Robert Mustacchi <rm@joyent.com> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov> 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
This commit is contained in:
parent
dbeb879699
commit
38240ebd7a
@ -596,19 +596,15 @@ dbuf_evict_notify(void)
|
|||||||
if (tsd_get(zfs_dbuf_evict_key) != NULL)
|
if (tsd_get(zfs_dbuf_evict_key) != NULL)
|
||||||
return;
|
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) {
|
if (refcount_count(&dbuf_cache_size) > dbuf_cache_max_bytes) {
|
||||||
boolean_t evict_now = B_FALSE;
|
if (dbuf_cache_above_hiwater())
|
||||||
|
|
||||||
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) {
|
|
||||||
dbuf_evict_one();
|
dbuf_evict_one();
|
||||||
}
|
cv_signal(&dbuf_evict_cv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user