On Thu, Nov 19, 2026 at 06:43:08PM +0100, Andi Shyti wrote:
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c 
> > b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > index bf9e7480f0f5..748772c358ac 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > @@ -316,9 +316,15 @@ void __shmem_writeback(size_t size, struct 
> > address_space *mapping)
> >      * leaving only CPU mmapings around) and add those folios to the LRU
> >      * instead of invoking writeback so they are aged and paged out
> >      * as normal.
> > +    *
> > +    * The same goes for a folio with references beyond the page cache
> > +    * and writeback_iter(). A folio that was just unmapped can still be
> > +    * written through a stale TLB entry until the unmapping side flushes
> > +    * the TLB and drops its reference. pageout() checks the same.
> >      */
> >     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()").

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

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

Reply via email to