Commit 84052c3c authored by Tang Junhui's avatar Tang Junhui Committed by Khalid Elmously

bcache: add journal statistic

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

Sometimes, Journal takes up a lot of CPU, we need statistics
to know what's the journal is doing. So this patch provide
some journal statistics:
1) reclaim: how many times the journal try to reclaim resource,
   usually the journal bucket or/and the pin are exhausted.
2) flush_write: how many times the journal try to flush btree node
   to cache device, usually the journal bucket are exhausted.
3) retry_flush_write: how many times the journal retry to flush
   the next btree node, usually the previous tree node have been
   flushed by other thread.
we show these statistic by sysfs interface. Through these statistics
We can totally see the status of journal module when the CPU is too
high.
Signed-off-by: default avatarTang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: default avatarMichael Lyle <mlyle@lyle.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
(cherry picked from commit a728eacb)
Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 5e31ee24
...@@ -646,6 +646,10 @@ struct cache_set { ...@@ -646,6 +646,10 @@ struct cache_set {
atomic_long_t writeback_keys_done; atomic_long_t writeback_keys_done;
atomic_long_t writeback_keys_failed; atomic_long_t writeback_keys_failed;
atomic_long_t reclaim;
atomic_long_t flush_write;
atomic_long_t retry_flush_write;
enum { enum {
ON_ERROR_UNREGISTER, ON_ERROR_UNREGISTER,
ON_ERROR_PANIC, ON_ERROR_PANIC,
......
...@@ -391,6 +391,8 @@ static void btree_flush_write(struct cache_set *c) ...@@ -391,6 +391,8 @@ static void btree_flush_write(struct cache_set *c)
*/ */
struct btree *b, *best; struct btree *b, *best;
unsigned i; unsigned i;
atomic_long_inc(&c->flush_write);
retry: retry:
best = NULL; best = NULL;
...@@ -411,6 +413,7 @@ static void btree_flush_write(struct cache_set *c) ...@@ -411,6 +413,7 @@ static void btree_flush_write(struct cache_set *c)
if (!btree_current_write(b)->journal) { if (!btree_current_write(b)->journal) {
mutex_unlock(&b->write_lock); mutex_unlock(&b->write_lock);
/* We raced */ /* We raced */
atomic_long_inc(&c->retry_flush_write);
goto retry; goto retry;
} }
...@@ -492,6 +495,8 @@ static void journal_reclaim(struct cache_set *c) ...@@ -492,6 +495,8 @@ static void journal_reclaim(struct cache_set *c)
unsigned iter, n = 0; unsigned iter, n = 0;
atomic_t p; atomic_t p;
atomic_long_inc(&c->reclaim);
while (!atomic_read(&fifo_front(&c->journal.pin))) while (!atomic_read(&fifo_front(&c->journal.pin)))
fifo_pop(&c->journal.pin, p); fifo_pop(&c->journal.pin, p);
......
...@@ -63,6 +63,9 @@ read_attribute(bset_tree_stats); ...@@ -63,6 +63,9 @@ read_attribute(bset_tree_stats);
read_attribute(state); read_attribute(state);
read_attribute(cache_read_races); read_attribute(cache_read_races);
read_attribute(reclaim);
read_attribute(flush_write);
read_attribute(retry_flush_write);
read_attribute(writeback_keys_done); read_attribute(writeback_keys_done);
read_attribute(writeback_keys_failed); read_attribute(writeback_keys_failed);
read_attribute(io_errors); read_attribute(io_errors);
...@@ -546,6 +549,15 @@ SHOW(__bch_cache_set) ...@@ -546,6 +549,15 @@ SHOW(__bch_cache_set)
sysfs_print(cache_read_races, sysfs_print(cache_read_races,
atomic_long_read(&c->cache_read_races)); atomic_long_read(&c->cache_read_races));
sysfs_print(reclaim,
atomic_long_read(&c->reclaim));
sysfs_print(flush_write,
atomic_long_read(&c->flush_write));
sysfs_print(retry_flush_write,
atomic_long_read(&c->retry_flush_write));
sysfs_print(writeback_keys_done, sysfs_print(writeback_keys_done,
atomic_long_read(&c->writeback_keys_done)); atomic_long_read(&c->writeback_keys_done));
sysfs_print(writeback_keys_failed, sysfs_print(writeback_keys_failed,
...@@ -728,6 +740,9 @@ static struct attribute *bch_cache_set_internal_files[] = { ...@@ -728,6 +740,9 @@ static struct attribute *bch_cache_set_internal_files[] = {
&sysfs_bset_tree_stats, &sysfs_bset_tree_stats,
&sysfs_cache_read_races, &sysfs_cache_read_races,
&sysfs_reclaim,
&sysfs_flush_write,
&sysfs_retry_flush_write,
&sysfs_writeback_keys_done, &sysfs_writeback_keys_done,
&sysfs_writeback_keys_failed, &sysfs_writeback_keys_failed,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment