diff mbox series

[SRU,F,1/3] bcache: remove member accessed from struct btree

Message ID 20201021015902.19223-2-matthew.ruffell@canonical.com
State New
Headers show
Series bcache: Issues with large IO wait in bch_mca_scan() when shrinker is enabled | expand

Commit Message

Matthew Ruffell Oct. 21, 2020, 1:59 a.m. UTC
From: Coly Li <colyli@suse.de>

BugLink: https://bugs.launchpad.net/bugs/1898786

The member 'accessed' of struct btree is used in bch_mca_scan() when
shrinking btree node caches. The original idea is, if b->accessed is
set, clean it and look at next btree node cache from c->btree_cache
list, and only shrink the caches whose b->accessed is cleaned. Then
only cold btree node cache will be shrunk.

But when I/O pressure is high, it is very probably that b->accessed
of a btree node cache will be set again in bch_btree_node_get()
before bch_mca_scan() selects it again. Then there is no chance for
bch_mca_scan() to shrink enough memory back to slub or slab system.

This patch removes member accessed from struct btree, then once a
btree node ache is selected, it will be immediately shunk. By this
change, bch_mca_scan() may release btree node cahce more efficiently.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit 125d98edd11464c8e0ec9eaaba7d682d0f832686)
Signed-off-by: Matthew Ruffell <matthew.ruffell@canonical.com>
 drivers/md/bcache/btree.c | 8 ++------
 drivers/md/bcache/btree.h | 2 --
 2 files changed, 2 insertions(+), 8 deletions(-)
diff mbox series


diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 8d06105fc9ff..050f1c333d4e 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -749,14 +749,12 @@  static unsigned long bch_mca_scan(struct shrinker *shrink,
 		b = list_first_entry(&c->btree_cache, struct btree, list);
-		if (!b->accessed &&
-		    !mca_reap(b, 0, false)) {
+		if (!mca_reap(b, 0, false)) {
 			rw_unlock(true, b);
-		} else
-			b->accessed = 0;
+		}
@@ -1064,7 +1062,6 @@  struct btree *bch_btree_node_get(struct cache_set *c, struct btree_op *op,
 	b->parent = parent;
-	b->accessed = 1;
 	for (; i <= b->keys.nsets && b->keys.set[i].size; i++) {
@@ -1155,7 +1152,6 @@  struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op,
 		goto retry;
-	b->accessed = 1;
 	b->parent = parent;
 	bch_bset_init_next(&b->keys, b->keys.set->data, bset_magic(&b->c->sb));
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h
index 76cfd121a486..f4dcca449391 100644
--- a/drivers/md/bcache/btree.h
+++ b/drivers/md/bcache/btree.h
@@ -121,8 +121,6 @@  struct btree {
 	/* Key/pointer for this btree node */
-	/* Single bit - set when accessed, cleared by shrinker */
-	unsigned long		accessed;
 	unsigned long		seq;
 	struct rw_semaphore	lock;
 	struct cache_set	*c;