]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bcachefs: Tweak btree key cache shrinker so it actually frees
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 20 Apr 2024 19:35:40 +0000 (15:35 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 20 Apr 2024 21:06:20 +0000 (17:06 -0400)
commitadfe9357c39e251ffe22ceaa1edb4b7662ed76e6
tree295f094c2e92f9d5ab00b8695710d874d654ee94
parent6e4d9bd110e293513c3c2a3ff2dfa0a0735699e0
bcachefs: Tweak btree key cache shrinker so it actually frees

Freeing key cache items is a multi stage process; we need to wait for an
SRCU grace period to elapse, and we handle this ourselves - partially to
avoid callback overhead, but primarily so that when allocating we can
first allocate from the freed items waiting for an SRCU grace period.

Previously, the shrinker was counting the items on the 'waiting for SRCU
grace period' lists as items being scanned, but this meant that too many
items waiting for an SRCU grace period could prevent it from doing any
work at all.

After this, we're seeing that items skipped due to the accessed bit are
the main cause of the shrinker not making any progress, and we actually
want the key cache shrinker to run quite aggressively because reclaimed
items will still generally be found (more compactly) in the btree node
cache - so we also tweak the shrinker to not count those against
nr_to_scan.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_key_cache.c