Re: [PATCH v2 1/3] mm: kick writeback flusher instead of inline flush for IOCB_DONTCACHE
From: Jan Kara
Date: Thu Apr 09 2026 - 03:21:49 EST
On Wed 08-04-26 22:50:59, Christoph Hellwig wrote:
> On Wed, Apr 08, 2026 at 10:25:21AM -0400, Jeff Layton wrote:
> > +/**
> > + * 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.
This is all true and I can certainly construct a workload where this
behavior will lead to big regressions in performance - for example one
process creating say 1G temporary file and deleting it shortly after
creation + one process doing small DONTCACHE writes. Before this change
only DONTCACHE writes will make it to the disk and temporary file will only
be in the page cache, after this change you pay for allocating, writing
back, and deleting the temporary file.
> 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.
But I'm not sure how you imagine this would work without restricting
writeback to particular inodes. Maybe we could mark inodes which have
folios with dropbehind set and make flush worker only write such inodes?
That would probably require tracking number of folios with dropbehind flag
per inode but that wouldn't be too bad. Or we could just lazily clear this
"inode has dropbehind folios" flag once the inode is clean.
Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR