Re: [PATCH v2 1/3] mm: kick writeback flusher instead of inline flush for IOCB_DONTCACHE
From: Christoph Hellwig
Date: Thu Apr 09 2026 - 01:51:25 EST
On Wed, Apr 08, 2026 at 10:25:21AM -0400, Jeff Layton wrote:
> Replace the inline filemap_flush_range() call with a
> wakeup_flusher_threads_bdi() call that kicks the BDI's flusher thread
> to drain dirty pages in the background. This moves writeback
> submission completely off the writer's hot path. The flusher thread
> handles writeback asynchronously, naturally coalescing and rate-limiting
> I/O without any explicit skip-if-busy or dirty pressure checks.
Having numbers showing the benefit here would be very useful.
> +/**
> + * filemap_dontcache_kick_writeback - kick flusher for IOCB_DONTCACHE writes
> + * @mapping: address_space that was just written to
> + *
> + * Wake the BDI flusher thread to start writeback of dirty pages in the
> + * background.
> + */
> +void filemap_dontcache_kick_writeback(struct address_space *mapping)
> +{
> + wakeup_flusher_threads_bdi(inode_to_bdi(mapping->host),
> + WB_REASON_DONTCACHE);
> +}
wakeup_flusher_threads_bdi ends up calling wb_start_writeback eventually,
which sets WB_start_all, pushes the reason to start_all_reason and then
does the actual wakeup.
The flusher thread then through wb_check_start_all does a WB_SYNC_NONE
writeback based on get_nr_dirty_pages. Which seems wrong - we don't
want to do a huge writeback evertime the some DONTCACHE write finished.
So I think you'll want a new WB_start_dontcache bit, a new
get_nr_dontcache_pages() helper on a new node counter, etc.
> +EXPORT_SYMBOL(filemap_dontcache_kick_writeback);
EXPORT_SYMBOL_GPL, please.