Skip to content

ARC: Notify dbuf cache about target size reduction #17314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sys/dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ int dbuf_dnode_findbp(dnode_t *dn, uint64_t level, uint64_t blkid,

void dbuf_init(void);
void dbuf_fini(void);
void dbuf_cache_reduce_target_size(void);

boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);

Expand Down
8 changes: 8 additions & 0 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
#include <sys/dsl_pool.h>
#include <sys/multilist.h>
#include <sys/abd.h>
#include <sys/dbuf.h>
#include <sys/zil.h>
#include <sys/fm/fs/zfs.h>
#include <sys/callb.h>
Expand Down Expand Up @@ -4555,6 +4556,13 @@ arc_reduce_target_size(uint64_t to_free)
to_free = 0;
}

/*
* Since dbuf cache size is a fraction of target ARC size, we should
* notify dbuf about the reduction, which might be significant,
* especially if current ARC size was much smaller than the target.
*/
dbuf_cache_reduce_target_size();

/*
* Whether or not we reduced the target size, request eviction if the
* current size is over it now, since caller obviously wants some RAM.
Expand Down
13 changes: 13 additions & 0 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,19 @@ dbuf_evict_notify(uint64_t size)
}
}

/*
* Since dbuf cache size is a fraction of target ARC size, ARC calls this when
* its target size is reduced due to memory pressure.
*/
void
dbuf_cache_reduce_target_size(void)
{
uint64_t size = zfs_refcount_count(&dbuf_caches[DB_DBUF_CACHE].size);

if (size > dbuf_cache_target_bytes())
cv_signal(&dbuf_evict_cv);
}

static int
dbuf_kstat_update(kstat_t *ksp, int rw)
{
Expand Down
Loading