* [PATCH v1 0/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs
@ 2026-03-26 23:46 Joanne Koong
2026-03-26 23:46 ` [PATCH v1 1/1] " Joanne Koong
0 siblings, 1 reply; 6+ messages in thread
From: Joanne Koong @ 2026-03-26 23:46 UTC (permalink / raw)
To: akpm; +Cc: jack, willy, miklos, linux-mm, linux-fsdevel
This patch has a dependency on the writeback regression fix in [1]. This is
submitted as a separate patchset from [1] because [1] is a fix targeting the
7.0 rc cycle while this patch is an optimization that targets the next merge
window.
Thanks,
Joanne
[1] https://lore.kernel.org/linux-fsdevel/20260326215127.3857682-1-joannelkoong@gmail.com/
Joanne Koong (1):
mm: start background writeback based on per-wb threshold for
strictlimit BDIs
mm/page-writeback.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v1 1/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs 2026-03-26 23:46 [PATCH v1 0/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs Joanne Koong @ 2026-03-26 23:46 ` Joanne Koong 2026-03-27 0:42 ` Andrew Morton 2026-03-27 16:07 ` Jan Kara 0 siblings, 2 replies; 6+ messages in thread From: Joanne Koong @ 2026-03-26 23:46 UTC (permalink / raw) To: akpm; +Cc: jack, willy, miklos, linux-mm, linux-fsdevel The proactive nr_dirty > gdtc->bg_thresh check in balance_dirty_pages() only checks the global dirty threshold to start background writeback while the writer is still free-running, but for strictlimit BDIs (eg fuse), the per-wb dirty count can exceed the per-wb background threshold while the global threshold is not yet exceeded, so background writeback for this case never gets proactively started. Add a per-wb threshold check for strictlimit BDIs so that background writeback is started when wb_dirty exceeds wb_bg_thresh, which drains dirty pages before the writer hits the throttle wall, matching the proactive behavior that the global check provides for non-strictlimit BDIs. fio runs on fuse show about a 3-4% improvement in perf for buffered writes: fio --name=writeback_test --ioengine=psync --rw=write --bs=128k \ --size=2G --numjobs=4 --ramp_time=10 --runtime=20 \ --time_based --group_reporting=1 --direct=0 Signed-off-by: Joanne Koong <joannelkoong@gmail.com> --- mm/page-writeback.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c1a4b32af1a7..30f3d5a6270f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1835,7 +1835,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, balance_domain_limits(mdtc, strictlimit); } - if (nr_dirty > gdtc->bg_thresh && !writeback_in_progress(wb)) + if (!writeback_in_progress(wb) && + (nr_dirty > gdtc->bg_thresh || + (strictlimit && gdtc->wb_dirty > gdtc->wb_bg_thresh))) wb_start_background_writeback(wb); /* @@ -1862,15 +1864,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, * Unconditionally start background writeback if it's not * already in progress. We need to do this because the global * dirty threshold check above (nr_dirty > gdtc->bg_thresh) - * doesn't account for these cases: - * - * a) strictlimit BDIs: throttling is calculated using per-wb - * thresholds. The per-wb threshold can be exceeded even when - * nr_dirty < gdtc->bg_thresh - * - * b) memcg-based throttling: memcg uses its own dirty count and - * thresholds and can trigger throttling even when global - * nr_dirty < gdtc->bg_thresh + * doesn't account for the memcg-based throttling case. memcg + * uses its own dirty count and thresholds and can trigger + * throttling even when global nr_dirty < gdtc->bg_thresh * * Writeback needs to be started else the writer stalls in the * throttle loop waiting for dirty pages to be written back -- 2.52.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs 2026-03-26 23:46 ` [PATCH v1 1/1] " Joanne Koong @ 2026-03-27 0:42 ` Andrew Morton 2026-03-27 0:50 ` Andrew Morton 2026-03-27 16:07 ` Jan Kara 1 sibling, 1 reply; 6+ messages in thread From: Andrew Morton @ 2026-03-27 0:42 UTC (permalink / raw) To: Joanne Koong; +Cc: jack, willy, miklos, linux-mm, linux-fsdevel On Thu, 26 Mar 2026 16:46:29 -0700 Joanne Koong <joannelkoong@gmail.com> wrote: > The proactive nr_dirty > gdtc->bg_thresh check in balance_dirty_pages() > only checks the global dirty threshold to start background writeback > while the writer is still free-running, but for strictlimit BDIs (eg > fuse), the per-wb dirty count can exceed the per-wb background threshold > while the global threshold is not yet exceeded, so background writeback > for this case never gets proactively started. > > Add a per-wb threshold check for strictlimit BDIs so that background > writeback is started when wb_dirty exceeds wb_bg_thresh, which drains > dirty pages before the writer hits the throttle wall, matching the > proactive behavior that the global check provides for non-strictlimit > BDIs. > > fio runs on fuse show about a 3-4% improvement in perf for buffered > writes: > fio --name=writeback_test --ioengine=psync --rw=write --bs=128k \ > --size=2G --numjobs=4 --ramp_time=10 --runtime=20 \ > --time_based --group_reporting=1 --direct=0 > Thanks. Your v1 patch's changelog had useful information showing the performance impact on fuse. I've pasted one sentence from that changelog into my copy of this changelog, but please don't be sparing in describing the importance of a fix. Also, we lost the Fixes tag. I've added Fixes: 64dd89ae01f2 ("mm/block/fs: remove laptop_mode") Cc: <stable@vger.kernel.org> to my copy of this v2 patch. Please confirm that this is appropriate. > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -1862,15 +1864,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, > * Unconditionally start background writeback if it's not > * already in progress. We need to do this because the global > * dirty threshold check above (nr_dirty > gdtc->bg_thresh) > - * doesn't account for these cases: > - * > - * a) strictlimit BDIs: throttling is calculated using per-wb > - * thresholds. The per-wb threshold can be exceeded even when > - * nr_dirty < gdtc->bg_thresh > - * > - * b) memcg-based throttling: memcg uses its own dirty count and > - * thresholds and can trigger throttling even when global > - * nr_dirty < gdtc->bg_thresh > + * doesn't account for the memcg-based throttling case. memcg > + * uses its own dirty count and thresholds and can trigger > + * throttling even when global nr_dirty < gdtc->bg_thresh > * > * Writeback needs to be started else the writer stalls in the > * throttle loop waiting for dirty pages to be written back My copy of balance_dirty_pages() doesn't have this comment block. I assume you're patching a different kernel version. I dropped this hunk. Please check current Linus mainline and see if there's somewhere else where you'd like to add this information. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs 2026-03-27 0:42 ` Andrew Morton @ 2026-03-27 0:50 ` Andrew Morton 2026-03-27 15:59 ` Joanne Koong 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2026-03-27 0:50 UTC (permalink / raw) To: Joanne Koong, jack, willy, miklos, linux-mm, linux-fsdevel On Thu, 26 Mar 2026 17:42:37 -0700 Andrew Morton <akpm@linux-foundation.org> wrote: > > fio runs on fuse show about a 3-4% improvement in perf for buffered > > writes: > > fio --name=writeback_test --ioengine=psync --rw=write --bs=128k \ > > --size=2G --numjobs=4 --ramp_time=10 --runtime=20 \ > > --time_based --group_reporting=1 --direct=0 > > > > Thanks. > > [bunch of nonsense] > argh, sorry, I didn't read your [0/N]. Ignore. btw, a [0/N] isn't really needed for a singleton patch - best to just put everything into the patch's changelog. Transient info such as "this depends on my other patch" can be placed below the singleton patch's "---" separator. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs 2026-03-27 0:50 ` Andrew Morton @ 2026-03-27 15:59 ` Joanne Koong 0 siblings, 0 replies; 6+ messages in thread From: Joanne Koong @ 2026-03-27 15:59 UTC (permalink / raw) To: Andrew Morton; +Cc: jack, willy, miklos, linux-mm, linux-fsdevel On Thu, Mar 26, 2026 at 5:50 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Thu, 26 Mar 2026 17:42:37 -0700 Andrew Morton <akpm@linux-foundation.org> wrote: > > btw, a [0/N] isn't really needed for a singleton patch - best to just > put everything into the patch's changelog. > > Transient info such as "this depends on my other patch" can be placed > below the singleton patch's "---" separator. Ah I see, I will do that instead next time, sorry for the confusion. Thanks, Joanne ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs 2026-03-26 23:46 ` [PATCH v1 1/1] " Joanne Koong 2026-03-27 0:42 ` Andrew Morton @ 2026-03-27 16:07 ` Jan Kara 1 sibling, 0 replies; 6+ messages in thread From: Jan Kara @ 2026-03-27 16:07 UTC (permalink / raw) To: Joanne Koong; +Cc: akpm, jack, willy, miklos, linux-mm, linux-fsdevel On Thu 26-03-26 16:46:29, Joanne Koong wrote: > The proactive nr_dirty > gdtc->bg_thresh check in balance_dirty_pages() > only checks the global dirty threshold to start background writeback > while the writer is still free-running, but for strictlimit BDIs (eg > fuse), the per-wb dirty count can exceed the per-wb background threshold > while the global threshold is not yet exceeded, so background writeback > for this case never gets proactively started. > > Add a per-wb threshold check for strictlimit BDIs so that background > writeback is started when wb_dirty exceeds wb_bg_thresh, which drains > dirty pages before the writer hits the throttle wall, matching the > proactive behavior that the global check provides for non-strictlimit > BDIs. > > fio runs on fuse show about a 3-4% improvement in perf for buffered > writes: > fio --name=writeback_test --ioengine=psync --rw=write --bs=128k \ > --size=2G --numjobs=4 --ramp_time=10 --runtime=20 \ > --time_based --group_reporting=1 --direct=0 > > Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Looks good. Thanks for improving these! Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > mm/page-writeback.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index c1a4b32af1a7..30f3d5a6270f 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -1835,7 +1835,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, > balance_domain_limits(mdtc, strictlimit); > } > > - if (nr_dirty > gdtc->bg_thresh && !writeback_in_progress(wb)) > + if (!writeback_in_progress(wb) && > + (nr_dirty > gdtc->bg_thresh || > + (strictlimit && gdtc->wb_dirty > gdtc->wb_bg_thresh))) > wb_start_background_writeback(wb); > > /* > @@ -1862,15 +1864,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, > * Unconditionally start background writeback if it's not > * already in progress. We need to do this because the global > * dirty threshold check above (nr_dirty > gdtc->bg_thresh) > - * doesn't account for these cases: > - * > - * a) strictlimit BDIs: throttling is calculated using per-wb > - * thresholds. The per-wb threshold can be exceeded even when > - * nr_dirty < gdtc->bg_thresh > - * > - * b) memcg-based throttling: memcg uses its own dirty count and > - * thresholds and can trigger throttling even when global > - * nr_dirty < gdtc->bg_thresh > + * doesn't account for the memcg-based throttling case. memcg > + * uses its own dirty count and thresholds and can trigger > + * throttling even when global nr_dirty < gdtc->bg_thresh > * > * Writeback needs to be started else the writer stalls in the > * throttle loop waiting for dirty pages to be written back > -- > 2.52.0 > -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-27 16:07 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-03-26 23:46 [PATCH v1 0/1] mm: start background writeback based on per-wb threshold for strictlimit BDIs Joanne Koong 2026-03-26 23:46 ` [PATCH v1 1/1] " Joanne Koong 2026-03-27 0:42 ` Andrew Morton 2026-03-27 0:50 ` Andrew Morton 2026-03-27 15:59 ` Joanne Koong 2026-03-27 16:07 ` Jan Kara
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox