Skip to content

Commit 299f7ba

Browse files
amotinixhamza
authored andcommitted
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 15ac9f5 commit 299f7ba

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
@@ -446,6 +446,7 @@ int dbuf_dnode_findbp(dnode_t *dn, uint64_t level, uint64_t blkid,
446446

447447
void dbuf_init(void);
448448
void dbuf_fini(void);
449+
void dbuf_cache_reduce_target_size(void);
449450

450451
boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);
451452

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>
@@ -4440,6 +4441,13 @@ arc_reduce_target_size(uint64_t to_free)
44404441
to_free = 0;
44414442
}
44424443

4444+
/*
4445+
* Since dbuf cache size is a fraction of target ARC size, we should
4446+
* notify dbuf about the reduction, which might be significant,
4447+
* especially if current ARC size was much smaller than the target.
4448+
*/
4449+
dbuf_cache_reduce_target_size();
4450+
44434451
/*
44444452
* Whether or not we reduced the target size, request eviction if the
44454453
* 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)