Commit bf2b356a authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Leave a buffer in the btree key cache to avoid lock thrashing

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2760bfe3
...@@ -915,6 +915,14 @@ static unsigned long bch2_btree_key_cache_count(struct shrinker *shrink, ...@@ -915,6 +915,14 @@ static unsigned long bch2_btree_key_cache_count(struct shrinker *shrink,
long nr = atomic_long_read(&bc->nr_keys) - long nr = atomic_long_read(&bc->nr_keys) -
atomic_long_read(&bc->nr_dirty); atomic_long_read(&bc->nr_dirty);
/*
* Avoid hammering our shrinker too much if it's nearly empty - the
* shrinker code doesn't take into account how big our cache is, if it's
* mostly empty but the system is under memory pressure it causes nasty
* lock contention:
*/
nr -= 128;
return max(0L, nr); return max(0L, nr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment