diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-11 20:14:54 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:38 -0400 |
commit | 5c0bb66ae341c71e5f62c193ea4d7b0cf278a914 (patch) | |
tree | d7b3bcdc29039b2debad1c2bab4d91bb97f885f3 /fs/bcachefs/debug.c | |
parent | 4aba7d4569f70167edf183055e809a37cd73cdd1 (diff) | |
download | linux-5c0bb66ae341c71e5f62c193ea4d7b0cf278a914.tar.gz linux-5c0bb66ae341c71e5f62c193ea4d7b0cf278a914.tar.bz2 linux-5c0bb66ae341c71e5f62c193ea4d7b0cf278a914.zip |
bcachefs: Track the maximum btree_paths ever allocated by each transaction
We need a way to check if the machinery for handling btree_paths with in
a transaction is behaving reasonably, as it often has not been - we've
had bugs with transaction path overflows caused by duplicate paths and
plenty of other things.
This patch tracks, per transaction fn, the most btree paths ever
allocated by that transaction and makes it available in debugfs.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/debug.c')
-rw-r--r-- | fs/bcachefs/debug.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index d40846f99f52..c982b0d80c91 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -674,7 +674,29 @@ static ssize_t lock_held_stats_read(struct file *file, char __user *buf, prt_printf(&i->buf, "%s: ", c->btree_transaction_fns[i->iter]); prt_newline(&i->buf); printbuf_indent_add(&i->buf, 2); - bch2_time_stats_to_text(&i->buf, &s->lock_hold_times); + + mutex_lock(&s->lock); + + if (IS_ENABLED(CONFIG_BCACHEFS_LOCK_TIME_STATS)) { + prt_printf(&i->buf, "Lock hold times:"); + prt_newline(&i->buf); + + printbuf_indent_add(&i->buf, 2); + bch2_time_stats_to_text(&i->buf, &s->lock_hold_times); + printbuf_indent_sub(&i->buf, 2); + } + + if (s->max_paths_text) { + prt_printf(&i->buf, "Maximum allocated btree paths (%u):", s->nr_max_paths); + prt_newline(&i->buf); + + printbuf_indent_add(&i->buf, 2); + prt_str_indented(&i->buf, s->max_paths_text); + printbuf_indent_sub(&i->buf, 2); + } + + mutex_unlock(&s->lock); + printbuf_indent_sub(&i->buf, 2); prt_newline(&i->buf); i->iter++; @@ -723,10 +745,8 @@ void bch2_fs_debug_init(struct bch_fs *c) debugfs_create_file("journal_pins", 0400, c->fs_debug_dir, c->btree_debug, &journal_pins_ops); - if (IS_ENABLED(CONFIG_BCACHEFS_LOCK_TIME_STATS)) { - debugfs_create_file("btree_transaction_stats", 0400, c->fs_debug_dir, - c, &lock_held_stats_op); - } + debugfs_create_file("btree_transaction_stats", 0400, c->fs_debug_dir, + c, &lock_held_stats_op); c->btree_debug_dir = debugfs_create_dir("btrees", c->fs_debug_dir); if (IS_ERR_OR_NULL(c->btree_debug_dir)) |