All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, bzzz@whamcloud.com, artem.blagodarenko@gmail.com,
	sihara@ddn.com, adilger@dilger.ca,
	Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Subject: [PATCH v2 5/5] ext4: add proc files to monitor new structures
Date: Tue,  9 Feb 2021 12:28:57 -0800	[thread overview]
Message-ID: <20210209202857.4185846-6-harshadshirwadkar@gmail.com> (raw)
In-Reply-To: <20210209202857.4185846-1-harshadshirwadkar@gmail.com>

This patch adds a new file "mb_structs_summary" which allows us to see the
summary of the new allocator structures added in this series.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/ext4.h    |  1 +
 fs/ext4/mballoc.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/sysfs.c   |  2 ++
 3 files changed, 87 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0601c997c87f..39830c07c27e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2817,6 +2817,7 @@ int __init ext4_fc_init_dentry_cache(void);
 
 /* mballoc.c */
 extern const struct seq_operations ext4_mb_seq_groups_ops;
+extern const struct seq_operations ext4_mb_seq_structs_summary_ops;
 extern long ext4_mb_stats;
 extern long ext4_mb_max_to_scan;
 extern int ext4_seq_mb_stats_show(struct seq_file *seq, void *offset);
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 63562f5f42f1..d9cb74787a47 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2864,6 +2864,90 @@ int ext4_seq_mb_stats_show(struct seq_file *seq, void *offset)
 	return 0;
 }
 
+static void *ext4_mb_seq_structs_summary_start(struct seq_file *seq, loff_t *pos)
+{
+	struct super_block *sb = PDE_DATA(file_inode(seq->file));
+	unsigned long position;
+
+	read_lock(&EXT4_SB(sb)->s_mb_rb_lock);
+
+	if (*pos < 0 || *pos >= MB_NUM_ORDERS(sb) + 1)
+		return NULL;
+	position = *pos + 1;
+	return (void *) ((unsigned long) position);
+}
+
+static void *ext4_mb_seq_structs_summary_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	struct super_block *sb = PDE_DATA(file_inode(seq->file));
+	unsigned long position;
+
+	++*pos;
+	if (*pos < 0 || *pos >= MB_NUM_ORDERS(sb) + 1)
+		return NULL;
+	position = *pos + 1;
+	return (void *) ((unsigned long) position);
+}
+
+static int ext4_mb_seq_structs_summary_show(struct seq_file *seq, void *v)
+{
+	struct super_block *sb = PDE_DATA(file_inode(seq->file));
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	unsigned long position = ((unsigned long) v);
+	struct ext4_group_info *grp;
+	struct rb_node *n;
+	int count, min, max;
+
+	position--;
+
+	if (position >= MB_NUM_ORDERS(sb)) {
+		seq_puts(seq, "Tree\n");
+		n = rb_first(&sbi->s_mb_avg_fragment_size_root);
+		if (!n) {
+			seq_puts(seq, "<Empty>\n");
+			return 0;
+		}
+		grp = rb_entry(n, struct ext4_group_info, bb_avg_fragment_size_rb);
+		min = grp->bb_fragments ? grp->bb_free / grp->bb_fragments : 0;
+		count = 1;
+		while (rb_next(n)) {
+			count++;
+			n = rb_next(n);
+		}
+		grp = rb_entry(n, struct ext4_group_info, bb_avg_fragment_size_rb);
+		max = grp->bb_fragments ? grp->bb_free / grp->bb_fragments : 0;
+
+		seq_printf(seq, "Min: %d, Max: %d, Num Nodes: %d\n",
+			   min, max, count);
+		return 0;
+	}
+
+	if (position == 0)
+		seq_puts(seq, "Largest Free Order Lists:\n");
+
+	seq_printf(seq, "Order %ld list: ", position);
+	count = 0;
+	list_for_each_entry(grp, &sbi->s_mb_largest_free_orders[position],
+			    bb_largest_free_order_node)
+		count++;
+	seq_printf(seq, "%d Groups\n", count);
+	return 0;
+}
+
+static void ext4_mb_seq_structs_summary_stop(struct seq_file *seq, void *v)
+{
+	struct super_block *sb = PDE_DATA(file_inode(seq->file));
+
+	read_unlock(&EXT4_SB(sb)->s_mb_rb_lock);
+}
+
+const struct seq_operations ext4_mb_seq_structs_summary_ops = {
+	.start  = ext4_mb_seq_structs_summary_start,
+	.next   = ext4_mb_seq_structs_summary_next,
+	.stop   = ext4_mb_seq_structs_summary_stop,
+	.show   = ext4_mb_seq_structs_summary_show,
+};
+
 static struct kmem_cache *get_groupinfo_cache(int blocksize_bits)
 {
 	int cache_index = blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE;
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 752d1c261e2a..b78bc6b57bce 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -529,6 +529,8 @@ int ext4_register_sysfs(struct super_block *sb)
 				&ext4_mb_seq_groups_ops, sb);
 		proc_create_single_data("mb_stats", 0444, sbi->s_proc,
 				ext4_seq_mb_stats_show, sb);
+		proc_create_seq_data("mb_structs_summary", 0444, sbi->s_proc,
+				&ext4_mb_seq_structs_summary_ops, sb);
 	}
 	return 0;
 }
-- 
2.30.0.478.g8a0d178c01-goog


  parent reply	other threads:[~2021-02-09 20:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 20:28 Improve group scanning in mballoc Harshad Shirwadkar
2021-02-09 20:28 ` [PATCH v2 1/5] ext4: drop s_mb_bal_lock and convert protected fields to atomic Harshad Shirwadkar
2021-02-09 20:28 ` [PATCH v2 2/5] ext4: add mballoc stats proc file Harshad Shirwadkar
2021-02-11 23:49   ` Andreas Dilger
2021-02-12 16:52   ` Благодаренко Артём
2021-02-12 17:15     ` harshad shirwadkar
2021-02-09 20:28 ` [PATCH v2 3/5] ext4: add MB_NUM_ORDERS macro Harshad Shirwadkar
2021-02-16 10:45   ` Благодаренко Артём
2021-02-26  2:36     ` harshad shirwadkar
2021-02-09 20:28 ` [PATCH v2 4/5] ext4: improve cr 0 / cr 1 group scanning Harshad Shirwadkar
2021-02-10  9:00   ` [kbuild] " Dan Carpenter
2021-02-10  9:00     ` Dan Carpenter
2021-02-10  9:00     ` Dan Carpenter
2021-02-11  7:43   ` Alexey Lyashkov
2021-02-11  7:53     ` Alex Zhuravlev
2021-02-11 10:13       ` Alexey Lyashkov
2021-02-11 10:30   ` Andreas Dilger
2021-02-12 22:46   ` Andreas Dilger
2021-02-14 14:09   ` [ext4] ef4eebad9c: fxmark.hdd_ext4_no_jnl_MWCL_1_bufferedio.works/sec -9.8% regression kernel test robot
2021-02-14 14:09     ` kernel test robot
2021-02-26  3:22     ` Andreas Dilger
2021-03-03  2:56       ` Oliver Sang
2021-03-03  2:56         ` Oliver Sang
2021-02-16 19:39   ` [PATCH v2 4/5] ext4: improve cr 0 / cr 1 group scanning Благодаренко Артём
2021-02-16 22:36     ` Andreas Dilger
2021-02-22  3:59       ` harshad shirwadkar
2021-02-23 18:39         ` harshad shirwadkar
2021-02-26  3:43         ` Andreas Dilger
2021-02-26  4:06           ` harshad shirwadkar
2021-02-26  4:42             ` Andreas Dilger
2021-02-17 19:41   ` Благодаренко Артём
2021-02-09 20:28 ` Harshad Shirwadkar [this message]
2021-02-12 22:36   ` [PATCH v2 5/5] ext4: add proc files to monitor new structures Andreas Dilger
2021-02-16 16:55     ` harshad shirwadkar
  -- strict thread matches above, loose matches on Subject: below --
2021-02-10  8:03 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210209202857.4185846-6-harshadshirwadkar@gmail.com \
    --to=harshadshirwadkar@gmail.com \
    --cc=adilger@dilger.ca \
    --cc=artem.blagodarenko@gmail.com \
    --cc=bzzz@whamcloud.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sihara@ddn.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.