From: sashiko-bot@kernel.org
To: "Kiryl Shutsemau (Meta)" <kas@kernel.org>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>
Cc: "David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Andi Shyti" <andi.shyti@linux.intel.com>,
"David Hildenbrand" <david@kernel.org>,
"Hugh Dickins" <hughd@google.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-mm@kvack.org, kernel-team@meta.com
Subject: Re: [PATCH] drm/i915/gem: Skip writeback of shmem folios with extra references
Date: Fri, 20 Nov 2026 13:42:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-225261@kernel.org> (raw)
In-Reply-To: <20261119134243.3745282-1-kas@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/i915/gem: missing folio_unlock() after redirty in
__shmem_writeback()
- [High] drm/i915/gem: invalid dirty-tag writeback helpers in
__shmem_writeback()
--
commit eee676ed22d7c6fdff448f68a9e29b819f5d0c1e
Author: Kiryl Shutsemau (Meta) <kas@kernel.org>
drm/i915/gem: Skip writeback of shmem folios with extra references
This commit skips shmem writeback in __shmem_writeback() for folios that
carry references beyond the page cache and writeback_iter(), avoiding
writeback while an unmapped PMD may still have pending stores through a
stale TLB entry.
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index bf9e7480f0f54..748772c358acd 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))
> folio_redirty_for_writepage(&wbc, folio);
> else
> error = shmem_write_folio(folio);
[Severity: High]
Does skipping writeback here leave the folio locked?
writeback_iter() returns the folio locked via writeback_get_folio(), and
neither folio_redirty_for_writepage() nor the next writeback_iter() call
unlocks it. Routing unmapped folios with extra references into the
folio_redirty_for_writepage() branch without calling folio_unlock() leaves
PG_locked set permanently, deadlocking later faults, reclaim or truncation
on that folio.
[Severity: High]
Can writeback_iter() and folio_redirty_for_writepage() be used on a shmem
mapping?
writeback_get_folio() looks up folios by PAGECACHE_TAG_DIRTY, but
shmem_aops uses noop_dirty_folio, which sets PG_dirty without tagging
mapping->i_pages. As a result, writeback_iter() never finds dirty shmem
folios, and calling folio_redirty_for_writepage() on a shmem folio reaches
__folio_mark_dirty(), which triggers:
mm/page-writeback.c:__folio_mark_dirty() {
...
/*
* Shmem writeback relies on swap, and swap writeback is LRU based,
* not using the dirty mark.
*/
VM_WARN_ON_ONCE(folio_test_swapcache(folio) || shmem_mapping(mapping));
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119134243.3745282-1-kas@kernel.org?part=1
prev parent reply other threads:[~2026-11-20 13:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 13:42 [PATCH] drm/i915/gem: Skip writeback of shmem folios with extra references Kiryl Shutsemau (Meta)
2026-11-19 17:43 ` Andi Shyti
2026-11-20 13:17 ` Kiryl Shutsemau (Meta)
2026-11-19 19:14 ` ✓ i915.CI.BAT: success for " Patchwork
2026-11-20 13:42 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-225261@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=airlied@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hughd@google.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=rodrigo.vivi@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.