Re: [PATCH] mm/page-writeback: avoid unnecessary strictlimit background wakeups
From: Joanne Koong
Date: Tue Nov 03 2026 - 14:59:17 EST
On Sat, Oct 31, 2026 at 12:05 AM Avi Weiss <thnkslprpt@xxxxxxxxx> wrote:
>
> balance_dirty_pages() includes pages under writeback in
> gdtc->wb_dirty when checking the per-wb background threshold for
> strictlimit BDIs. However, wb_over_bg_thresh() only considers
> reclaimable dirty pages when deciding whether to start more
> background writeback.
>
> This can repeatedly wake the background worker even when there are
> too few dirty pages to write. In a 15-second FUSE writeback test,
> background wakeup requests dropped from 2657 to 682 (74% drop),
> while writeback_start events remained nearly unchanged at 99 and 98.
>
> Check wb_over_bg_thresh() before starting background writeback through
> the strictlimit condition. Leave the global background threshold
> check and the wakeup required for dirty throttling unchanged.
>
> Fixes: 0437906841d0 ("mm: start background writeback based on per-wb threshold for strictlimit BDIs")
> Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
> ---
> mm/page-writeback.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 499a35473e4f..cb0c58715b93 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -1826,7 +1826,8 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
>
> if (!writeback_in_progress(wb) &&
> (nr_dirty > gdtc->bg_thresh ||
> - (strictlimit && gdtc->wb_dirty > gdtc->wb_bg_thresh)))
> + (strictlimit && gdtc->wb_dirty > gdtc->wb_bg_thresh &&
> + wb_over_bg_thresh(wb))))
> wb_start_background_writeback(wb);
>
Thanks for the fix. It looks right to me. I think an alternative way
would be to save the wb_reclaimable value computed in
wb_dirty_limits() in struct dirty_throttle_control and just check if
"gdtc->wb_reclaimable > gdtc->wb_bg_thresh" which avoids the extra
wb_over_bg_thresh() calculations (but is slightly less precise for the
memcg case), but I don't think it matters much either way.
Reviewed-by: Joanne Koong <joannelkoong@xxxxxxxxx>
Thanks,
Joanne