Skip to content

Commit 89a8a91

Browse files
authored
ARC: Notify dbuf cache about target size reduction
ARC target size might drop significantly under memory pressure, especially if current ARC size was much smaller than the target. Since dbuf cache size is a fraction of the target ARC size, it might need eviction too. Aside of memory from the dbuf eviction itself, it might help ARC by making more buffers evictable. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Ameer Hamza <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#17314
1 parent 0aa83dc commit 89a8a91

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

include/sys/dbuf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ int dbuf_dnode_findbp(dnode_t *dn, uint64_t level, uint64_t blkid,
435435

436436
void dbuf_init(void);
437437
void dbuf_fini(void);
438+
void dbuf_cache_reduce_target_size(void);
438439

439440
boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);
440441

module/zfs/arc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
#include <sys/dsl_pool.h>
298298
#include <sys/multilist.h>
299299
#include <sys/abd.h>
300+
#include <sys/dbuf.h>
300301
#include <sys/zil.h>
301302
#include <sys/fm/fs/zfs.h>
302303
#include <sys/callb.h>
@@ -4555,6 +4556,13 @@ arc_reduce_target_size(uint64_t to_free)
45554556
to_free = 0;
45564557
}
45574558

4559+
/*
4560+
* Since dbuf cache size is a fraction of target ARC size, we should
4561+
* notify dbuf about the reduction, which might be significant,
4562+
* especially if current ARC size was much smaller than the target.
4563+
*/
4564+
dbuf_cache_reduce_target_size();
4565+
45584566
/*
45594567
* Whether or not we reduced the target size, request eviction if the
45604568
* current size is over it now, since caller obviously wants some RAM.

module/zfs/dbuf.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,19 @@ dbuf_evict_notify(uint64_t size)
872872
}
873873
}
874874

875+
/*
876+
* Since dbuf cache size is a fraction of target ARC size, ARC calls this when
877+
* its target size is reduced due to memory pressure.
878+
*/
879+
void
880+
dbuf_cache_reduce_target_size(void)
881+
{
882+
uint64_t size = zfs_refcount_count(&dbuf_caches[DB_DBUF_CACHE].size);
883+
884+
if (size > dbuf_cache_target_bytes())
885+
cv_signal(&dbuf_evict_cv);
886+
}
887+
875888
static int
876889
dbuf_kstat_update(kstat_t *ksp, int rw)
877890
{

0 commit comments

Comments
 (0)