summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2015-08-21 00:06:56 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2017-01-18 20:19:50 -0900
commit18e04e278dc60017d93b689a5ebfe4e1221228d3 (patch)
treea789066a0fb99defb0338bcca1b2bec8957e1299
parent75cb56d16f42a5f1ac1b1509c3d50c7e7637d07d (diff)
bcache: inline bch_increment_clock() fastpath
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--drivers/md/bcache/alloc.c8
-rw-r--r--drivers/md/bcache/alloc.h14
2 files changed, 14 insertions, 8 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index c7485e902718..b796c36e3282 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -156,18 +156,12 @@ static void bch_rescale_prios(struct cache_set *c, int rw)
}
}
-void bch_increment_clock(struct cache_set *c, int sectors, int rw)
+void bch_increment_clock_slowpath(struct cache_set *c, int rw)
{
long next = (c->nbuckets * c->sb.bucket_size) / 1024;
struct prio_clock *clock = rw ? &c->write_clock : &c->read_clock;
long r;
- /*
- * we only increment when 0.1% of the cache_set has been read
- * or written too, this determines if it's time
- */
- atomic_long_sub(sectors, &clock->rescale);
-
do {
r = atomic_long_read(&clock->rescale);
diff --git a/drivers/md/bcache/alloc.h b/drivers/md/bcache/alloc.h
index 9d44930eebb1..45e877c3d102 100644
--- a/drivers/md/bcache/alloc.h
+++ b/drivers/md/bcache/alloc.h
@@ -41,7 +41,19 @@ static inline size_t buckets_free_cache(struct cache *ca,
}
void bch_recalc_min_prio(struct cache *);
-void bch_increment_clock(struct cache_set *, int, int);
+void bch_increment_clock_slowpath(struct cache_set *, int);
+
+static inline void bch_increment_clock(struct cache_set *c, int sectors, int rw)
+{
+ struct prio_clock *clock = rw ? &c->write_clock : &c->read_clock;
+
+ /*
+ * we only increment when 0.1% of the cache_set has been read
+ * or written too, this determines if it's time
+ */
+ if (atomic_long_sub_return(sectors, &clock->rescale) < 0)
+ bch_increment_clock_slowpath(c, rw);
+}
bool bch_can_invalidate_bucket(struct cache *, struct bucket *);
void __bch_invalidate_one_bucket(struct cache *, struct bucket *);