Skip to content

Commit 5ae67ab

Browse files
author
Kent Overstreet
committed
bcachefs: Enable automatic shrinking for rhashtables
Since the key cache shrinker walks the rhashtable, a mostly empty rhashtable leads to really nasty reclaim performance issues. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 26447d2 commit 5ae67ab

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ static int bch2_btree_cache_cmp_fn(struct rhashtable_compare_arg *arg,
9191
}
9292

9393
static const struct rhashtable_params bch_btree_cache_params = {
94-
.head_offset = offsetof(struct btree, hash),
95-
.key_offset = offsetof(struct btree, hash_val),
96-
.key_len = sizeof(u64),
97-
.obj_cmpfn = bch2_btree_cache_cmp_fn,
94+
.head_offset = offsetof(struct btree, hash),
95+
.key_offset = offsetof(struct btree, hash_val),
96+
.key_len = sizeof(u64),
97+
.obj_cmpfn = bch2_btree_cache_cmp_fn,
98+
.automatic_shrinking = true,
9899
};
99100

100101
static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp)

fs/bcachefs/btree_key_cache.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ static int bch2_btree_key_cache_cmp_fn(struct rhashtable_compare_arg *arg,
3232
}
3333

3434
static const struct rhashtable_params bch2_btree_key_cache_params = {
35-
.head_offset = offsetof(struct bkey_cached, hash),
36-
.key_offset = offsetof(struct bkey_cached, key),
37-
.key_len = sizeof(struct bkey_cached_key),
38-
.obj_cmpfn = bch2_btree_key_cache_cmp_fn,
35+
.head_offset = offsetof(struct bkey_cached, hash),
36+
.key_offset = offsetof(struct bkey_cached, key),
37+
.key_len = sizeof(struct bkey_cached_key),
38+
.obj_cmpfn = bch2_btree_key_cache_cmp_fn,
39+
.automatic_shrinking = true,
3940
};
4041

4142
__flatten

fs/bcachefs/io_read.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ struct promote_op {
8484
};
8585

8686
static const struct rhashtable_params bch_promote_params = {
87-
.head_offset = offsetof(struct promote_op, hash),
88-
.key_offset = offsetof(struct promote_op, pos),
89-
.key_len = sizeof(struct bpos),
87+
.head_offset = offsetof(struct promote_op, hash),
88+
.key_offset = offsetof(struct promote_op, pos),
89+
.key_len = sizeof(struct bpos),
90+
.automatic_shrinking = true,
9091
};
9192

9293
static inline int should_promote(struct bch_fs *c, struct bkey_s_c k,

fs/bcachefs/movinggc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ struct buckets_in_flight {
3535
};
3636

3737
static const struct rhashtable_params bch_move_bucket_params = {
38-
.head_offset = offsetof(struct move_bucket_in_flight, hash),
39-
.key_offset = offsetof(struct move_bucket_in_flight, bucket.k),
40-
.key_len = sizeof(struct move_bucket_key),
38+
.head_offset = offsetof(struct move_bucket_in_flight, hash),
39+
.key_offset = offsetof(struct move_bucket_in_flight, bucket.k),
40+
.key_len = sizeof(struct move_bucket_key),
41+
.automatic_shrinking = true,
4142
};
4243

4344
static struct move_bucket_in_flight *

0 commit comments

Comments
 (0)