From: Kundan Kumar <kundan.kumar@samsung.com>
To: mcgrof@kernel.org
Cc: patches@lists.linux.dev, Kundan Kumar <kundan.kumar@samsung.com>,
Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH v2 08/15] writeback: add support to collect stats for all writeback ctxs
Date: Thu, 7 Aug 2025 10:26:59 +0530 [thread overview]
Message-ID: <20250807045706.2848-9-kundan.kumar@samsung.com> (raw)
In-Reply-To: <20250807045706.2848-1-kundan.kumar@samsung.com>
Modified stats collection to collect stats for all the writeback
contexts within a bdi.
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
mm/backing-dev.c | 72 ++++++++++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 30 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 754f2f6c6d7c..0a772d984ecf 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -50,6 +50,7 @@ struct wb_stats {
unsigned long nr_written;
unsigned long dirty_thresh;
unsigned long wb_thresh;
+ unsigned long state;
};
static struct dentry *bdi_debug_root;
@@ -81,6 +82,7 @@ static void collect_wb_stats(struct wb_stats *stats,
stats->nr_dirtied += wb_stat(wb, WB_DIRTIED);
stats->nr_written += wb_stat(wb, WB_WRITTEN);
stats->wb_thresh += wb_calc_thresh(wb, stats->dirty_thresh);
+ stats->state |= wb->state;
}
#ifdef CONFIG_CGROUP_WRITEBACK
@@ -89,22 +91,27 @@ static void bdi_collect_stats(struct backing_dev_info *bdi,
struct wb_stats *stats)
{
struct bdi_writeback *wb;
+ struct bdi_writeback_ctx *bdi_wb_ctx;
rcu_read_lock();
- list_for_each_entry_rcu(wb, &bdi->wb_ctx[0]->wb_list, bdi_node) {
- if (!wb_tryget(wb))
- continue;
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx)
+ list_for_each_entry_rcu(wb, &bdi_wb_ctx->wb_list, bdi_node) {
+ if (!wb_tryget(wb))
+ continue;
- collect_wb_stats(stats, wb);
- wb_put(wb);
- }
+ collect_wb_stats(stats, wb);
+ wb_put(wb);
+ }
rcu_read_unlock();
}
#else
static void bdi_collect_stats(struct backing_dev_info *bdi,
struct wb_stats *stats)
{
- collect_wb_stats(stats, &bdi->wb_ctx[0]->wb);
+ struct bdi_writeback_ctx *bdi_wb_ctx;
+
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx)
+ collect_wb_stats(stats, &bdi_wb_ctx->wb);
}
#endif
@@ -150,7 +157,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
stats.nr_io,
stats.nr_more_io,
stats.nr_dirty_time,
- !list_empty(&bdi->bdi_list), bdi->wb_ctx[0]->wb.state);
+ !list_empty(&bdi->bdi_list), stats.state);
return 0;
}
@@ -195,35 +202,40 @@ static int cgwb_debug_stats_show(struct seq_file *m, void *v)
{
struct backing_dev_info *bdi = m->private;
struct bdi_writeback *wb;
+ struct bdi_writeback_ctx *bdi_wb_ctx;
unsigned long background_thresh;
unsigned long dirty_thresh;
+ struct wb_stats stats;
global_dirty_limits(&background_thresh, &dirty_thresh);
+ stats.dirty_thresh = dirty_thresh;
rcu_read_lock();
- list_for_each_entry_rcu(wb, &bdi->wb_ctx[0]->wb_list, bdi_node) {
- struct wb_stats stats = { .dirty_thresh = dirty_thresh };
-
- if (!wb_tryget(wb))
- continue;
-
- collect_wb_stats(&stats, wb);
-
- /*
- * Calculate thresh of wb in writeback cgroup which is min of
- * thresh in global domain and thresh in cgroup domain. Drop
- * rcu lock because cgwb_calc_thresh may sleep in
- * cgroup_rstat_flush. We can do so here because we have a ref.
- */
- if (mem_cgroup_wb_domain(wb)) {
- rcu_read_unlock();
- stats.wb_thresh = min(stats.wb_thresh, cgwb_calc_thresh(wb));
- rcu_read_lock();
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx) {
+ list_for_each_entry_rcu(wb, &bdi_wb_ctx->wb_list, bdi_node) {
+ if (!wb_tryget(wb))
+ continue;
+
+ collect_wb_stats(&stats, wb);
+
+ /*
+ * Calculate thresh of wb in writeback cgroup which is
+ * min of thresh in global domain and thresh in cgroup
+ * domain. Drop rcu lock because cgwb_calc_thresh may
+ * sleep in cgroup_rstat_flush. We can do so here
+ * because we have a ref.
+ */
+ if (mem_cgroup_wb_domain(wb)) {
+ rcu_read_unlock();
+ stats.wb_thresh = min(stats.wb_thresh,
+ cgwb_calc_thresh(wb));
+ rcu_read_lock();
+ }
+
+ wb_stats_show(m, wb, &stats);
+
+ wb_put(wb);
}
-
- wb_stats_show(m, wb, &stats);
-
- wb_put(wb);
}
rcu_read_unlock();
--
2.25.1
next prev parent reply other threads:[~2025-08-07 4:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250807045740epcas5p4cdec49f07b86acf2eea832890393d256@epcas5p4.samsung.com>
2025-08-07 4:56 ` [PATCH v2 00/15] Test patch Parallelizing filesystem writeback Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 01/15] writeback: add infra for parallel writeback Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 02/15] writeback: add support to initialize and free multiple writeback ctxs Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 03/15] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 04/15] writeback: affine inode to a writeback ctx within a bdi Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 05/15] writeback: modify bdi_writeback search logic to search across all wb ctxs Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 06/15] writeback: invoke all writeback contexts for flusher and dirtytime writeback Kundan Kumar
2025-08-07 4:56 ` [PATCH v2 07/15] writeback: modify sync related functions to iterate over all writeback contexts Kundan Kumar
2025-08-07 4:56 ` Kundan Kumar [this message]
2025-08-07 4:57 ` [PATCH v2 09/15] f2fs: add support in f2fs to handle multiple " Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 10/15] fuse: add support for multiple writeback contexts in fuse Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 11/15] gfs2: add support in gfs2 to handle multiple writeback contexts Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 12/15] nfs: add support in nfs " Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 13/15] writeback: set the num of writeback contexts to number of online cpus Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 14/15] writeback: segregated allocation and free of writeback contexts Kundan Kumar
2025-08-07 4:57 ` [PATCH v2 15/15] writeback: added support to change the number of writebacks using a sysfs attribute Kundan Kumar
2025-08-07 18:34 ` [PATCH v2 00/15] Test patch Parallelizing filesystem writeback Luis Chamberlain
[not found] <CGME20250725155505epcas5p3981ad791c6c044c7abc6d232c05d54f9@epcas5p3.samsung.com>
2025-07-25 15:54 ` [PATCH v2 00/15] " Kundan Kumar
2025-07-25 15:54 ` [PATCH v2 08/15] writeback: add support to collect stats for all writeback ctxs Kundan Kumar
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=20250807045706.2848-9-kundan.kumar@samsung.com \
--to=kundan.kumar@samsung.com \
--cc=anuj20.g@samsung.com \
--cc=mcgrof@kernel.org \
--cc=patches@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox