aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_types.h
diff options
context:
space:
mode:
authorGravatar Kent Overstreet <kent.overstreet@gmail.com> 2022-06-17 01:07:54 -0400
committerGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-10-22 17:09:34 -0400
commit8f7f566f5774d36196bfa87bc097522fd497d4dc (patch)
tree5d60b9478018ad4baf119804cc0d4e980baf365a /fs/bcachefs/btree_types.h
parentbcachefs: Make IO in flight by copygc/rebalance configurable (diff)
downloadlinux-8f7f566f5774d36196bfa87bc097522fd497d4dc.tar.gz
linux-8f7f566f5774d36196bfa87bc097522fd497d4dc.tar.bz2
linux-8f7f566f5774d36196bfa87bc097522fd497d4dc.zip
bcachefs: btree key cache pcpu freedlist
Originally, the btree key cache code would always allocate new entries by reusing from the recently-freed list, if that list wasn't empty. But that behaviour was dropped, for lock contention reasons. But it seems that entries stranded on the freed list have been contributing to some of our oom issues, because long running btree transactions will prevent them from being freed. This patch re-adds allocating from the freed list, but it also adds percpu buffers to solve the lock contention issues - and the new percpu freed lists will improve the evict paths, too. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_types.h')
-rw-r--r--fs/bcachefs/btree_types.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h
index 4f3e1086a86b..2eb8cc11aec4 100644
--- a/fs/bcachefs/btree_types.h
+++ b/fs/bcachefs/btree_types.h
@@ -298,6 +298,11 @@ struct btree_iter {
struct bpos journal_pos;
};
+struct btree_key_cache_freelist {
+ struct bkey_cached *objs[16];
+ unsigned nr;
+};
+
struct btree_key_cache {
struct mutex lock;
struct rhashtable table;
@@ -305,8 +310,9 @@ struct btree_key_cache {
struct list_head freed;
struct shrinker shrink;
unsigned shrink_iter;
+ struct btree_key_cache_freelist __percpu *pcpu_freed;
- size_t nr_freed;
+ atomic_long_t nr_freed;
atomic_long_t nr_keys;
atomic_long_t nr_dirty;
};