]> git.proxmox.com Git - mirror_zfs.git/commit
Consider `dnode_t` allocations in dbuf cache size accounting
authorRob N <rob.norris@klarasystems.com>
Fri, 17 Nov 2023 21:25:53 +0000 (08:25 +1100)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2023 21:25:53 +0000 (13:25 -0800)
commit92dc4ad83d95b88c87b03682f50bbbde20513244
tree310d947c00672d5a4348516bec25b6e838110cf9
parent6c6fae6fae5547482a9b6160125be4ce66ee8216
Consider `dnode_t` allocations in dbuf cache size accounting

Entries in the dbuf cache contribute only the size of the dbuf data to
the cache size. Attached "user" data is not counted. This can lead to
the data currently "owned" by the cache consuming more memory accounting
appears to show. In some cases (eg a metadnode data block with all child
dnode_t slots allocated), the actual size can be as much as 3x as what
the cache believes it to be.

This is arguably correct behaviour, as the cache is only tracking the
size of the dbuf data, not even the overhead of the dbuf_t. On the other
hand, in the above case of dnodes, evicting cached metadnode dbufs is
the only current way to reclaim the dnode objects, and can lead to the
situation where the dbuf cache appears to be comfortably within its
target memory window and yet is holding enormous amounts of slab memory
that cannot be reclaimed.

This commit adds a facility for a dbuf user to artificially inflate the
apparent size of the dbuf for caching purposes. This at least allows for
cache tuning to be adjusted to match something closer to the real memory
overhead.

metadnode dbufs carry a >1KiB allocation per dnode in their user data.
This informs the dbuf cache machinery of that fact, allowing it to make
better decisions when evicting dbufs.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #15511
cmd/dbufstat.in
include/sys/dmu.h
module/zfs/dbuf.c
module/zfs/dbuf_stats.c
module/zfs/dnode.c