[PATCH v2 13/16] writeback: configure the num of writeback contexts between 0 and number of online cpus

Kundan Kumar
2025-10-14T12:11:27Z

The number of writeback contexts can be configured, with a valid range
between 0 and the number of online CPUs. Inodes are then distributed
across these contexts, enabling parallel writeback.

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
mm/backing-dev.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 0a772d984ecf..0a3204a3a3a3 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -1046,6 +1046,12 @@ int bdi_init(struct backing_dev_info *bdi)
bdi->min_ratio = 0;
bdi->max_ratio = 100 * BDI_RATIO_SCALE;
bdi->max_prop_frac = FPROP_FRAC_BASE;
+
+ /*
+ * User can configure nr_wb_ctx using the newly introduced sysfs knob.
+ * echo N > /sys/class/bdi/<maj>:<min>/nwritebacks
+ * Filesystem can also increase same during mount.
+ */
bdi->nr_wb_ctx = 1;
bdi->wb_ctx = kcalloc(bdi->nr_wb_ctx,
sizeof(struct bdi_writeback_ctx *),
--
2.25.1