Revert "bcache: add "clock" cache replacement policy" This reverts commit 55766dbc11bf6cb8516819a45a39544b967090f3. The interim patch has been replaced by an official commit 70bc173ce06be90b026bb00ea175567c91f006e4 bcache: reduce gc latency by processing less nodes and sleep less time BUG=b/466158659 TEST=presubmit RELEASE_NOTE=None cos-patch: bug Change-Id: I6dd97afc07e365b0e9da27c7932034ec5be8723d Signed-off-by: He Gao <hegao@google.com> Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/121927 Reviewed-by: Miri Amarilio <mirilio@google.com> Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com> Main-Branch-Verified: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com> Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/122027
diff --git a/Documentation/admin-guide/bcache.rst b/Documentation/admin-guide/bcache.rst index 2be2999..6fdb495 100644 --- a/Documentation/admin-guide/bcache.rst +++ b/Documentation/admin-guide/bcache.rst
@@ -616,7 +616,7 @@ Size of buckets cache_replacement_policy - One of either lru, fifo, random or clock. + One of either lru, fifo or random. discard Boolean; if on a discard/TRIM will be issued to each bucket before it is
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index fd65431..edb9a0f 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c
@@ -69,8 +69,7 @@ #include <linux/random.h> #include <trace/events/bcache.h> -#define MAX_OPEN_BUCKETS 128 -#define CHECK_PRIO_SLICES 16 +#define MAX_OPEN_BUCKETS 128 /* Bucket heap / gen */ @@ -212,41 +211,19 @@ static void invalidate_buckets_lru(struct cache *ca) } } -/* - * When check_prio is true, this FIFO policy examines the priority of the - * buckets and invalidates only the ones below a threshold in the priority - * ladder. As it goes, the threshold will be raised if not enough buckets are - * invalidated. Empty buckets are also invalidated. This evaulation resembles - * the LRU policy, and is used to approximate the classic clock-sweep cache - * replacement algorithm. - */ -static void invalidate_buckets_fifo(struct cache *ca, bool check_prio) +static void invalidate_buckets_fifo(struct cache *ca) { struct bucket *b; size_t checked = 0; - size_t check_quota = 0; - uint16_t prio_threshold = ca->set->min_prio; while (!fifo_full(&ca->free_inc)) { if (ca->fifo_last_bucket < ca->sb.first_bucket || ca->fifo_last_bucket >= ca->sb.nbuckets) ca->fifo_last_bucket = ca->sb.first_bucket; - if (check_prio && checked >= check_quota) { - BUG_ON(ca->set->min_prio > INITIAL_PRIO); - prio_threshold += - DIV_ROUND_UP(INITIAL_PRIO - ca->set->min_prio, - CHECK_PRIO_SLICES); - check_quota += DIV_ROUND_UP(ca->sb.nbuckets, - CHECK_PRIO_SLICES); - } - b = ca->buckets + ca->fifo_last_bucket++; - if (bch_can_invalidate_bucket(ca, b) && - (!check_prio || - b->prio <= prio_threshold || - !GC_SECTORS_USED(b))) + if (bch_can_invalidate_bucket(ca, b)) bch_invalidate_one_bucket(ca, b); if (++checked >= ca->sb.nbuckets) { @@ -292,14 +269,11 @@ static void invalidate_buckets(struct cache *ca) invalidate_buckets_lru(ca); break; case CACHE_REPLACEMENT_FIFO: - invalidate_buckets_fifo(ca, false); + invalidate_buckets_fifo(ca); break; case CACHE_REPLACEMENT_RANDOM: invalidate_buckets_random(ca); break; - case CACHE_REPLACEMENT_CLOCK: - invalidate_buckets_fifo(ca, true); - break; } }
diff --git a/drivers/md/bcache/bcache_ondisk.h b/drivers/md/bcache/bcache_ondisk.h index d45794e..6620a7f 100644 --- a/drivers/md/bcache/bcache_ondisk.h +++ b/drivers/md/bcache/bcache_ondisk.h
@@ -288,7 +288,6 @@ BITMASK(CACHE_REPLACEMENT, struct cache_sb, flags, 2, 3); #define CACHE_REPLACEMENT_LRU 0U #define CACHE_REPLACEMENT_FIFO 1U #define CACHE_REPLACEMENT_RANDOM 2U -#define CACHE_REPLACEMENT_CLOCK 3U BITMASK(BDEV_CACHE_MODE, struct cache_sb, flags, 0, 4); #define CACHE_MODE_WRITETHROUGH 0U
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index f2d1b2d..b3a34f3 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c
@@ -45,7 +45,6 @@ static const char * const cache_replacement_policies[] = { "lru", "fifo", "random", - "clock", NULL };