Re: [PATCH] drm/i915/gem: Skip writeback of shmem folios with extra references

From: Christoph Hellwig

Date: Wed Nov 25 2026 - 00:37:00 EST


On Fri, Nov 20, 2026 at 01:17:31PM +0000, Kiryl Shutsemau (Meta) wrote:
> > > while ((folio = writeback_iter(mapping, &wbc, folio, &error))) {
> > > - if (folio_mapped(folio))
> > > + if (folio_mapped(folio) ||
> > > + folio_ref_count(folio) != 1 + folio_nr_pages(folio))
> >
> > I don't think we need this fix in the current tree. The i915
> > writeback iterator already skips the shmem folio in the case you
> > describe, so the new refcount check doesn't change the outcome.
>
> Oh. It took me a while to see why.
>
> __shmem_writeback() asks writeback_iter() for PAGECACHE_TAG_DIRTY
> folios, and shmem never sets that tag, its ->dirty_folio is
> noop_dirty_folio(). So the loop body never runs for any folio, and
> hasn't since 776a853a43c9 ("i915: Use writeback_iter()").

Heh. I'm surprised no one noticed..

> That makes me question the whole writeback thing. What's going on
> there, and what's the plan?

I (and others) have been asking forever to get drm out of micro-managing
tmpfs. I guess given that this code path hasn't worked for a year and
a half is a pretty good indicator that this instance should simply
go away.