Re: [PATCH 2/7] mm: stop passing a writeback_control structure to shmem_writeout

Matthew Wilcox
2025-05-08T13:25:08Z

On Thu, May 08, 2025 at 07:47:44AM +0200, Christoph Hellwig wrote:
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -318,7 +318,7 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
> if (folio_mapped(folio))
> folio_redirty_for_writepage(&wbc, folio);
> else
> - error = shmem_writeout(folio, &wbc);
> + error = shmem_writeout(folio, NULL, NULL);
> }
> }

This got me to look at why we need to keep wbc in __shmem_writeback().
We only have it because folio_redirty_for_writepage() needs it. And
folio_redirty_for_writepage() only needs it because it updates
pages_skipped.

I'm not quite sure if we can simply call filemap_dirty_folio() here
or whether mapping_can_writeback() is true for shmem and we need to
do all the other things -- in which case we could just change that one
line to

if (wbc)
wbc->pages_skipped += nr;

and then pass NULL to folio_redirty_for_writepage() and delete the
wbc on the stack.