From: sashiko-bot@kernel.org
To: "Matthias Goergens" <matthias.goergens@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: unlock shmem folios after skipped writeback
Date: Mon, 14 Sep 2026 11:15:10 +0000 [thread overview]
Message-ID: <20260914111511.648711F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914105606.3997649-1-matthias.goergens@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] __shmem_writeback() limits writeback to SWAP_CLUSTER_MAX (32) pages, ignoring the requested size, which causes the shrinker to severely under-reclaim memory while reporting full reclaim success.
--
commit bda67bb2ffdd195685542c6f27e5b602b16ff109
Author: Matthias Goergens <matthias.goergens@gmail.com>
drm/i915: unlock shmem folios after skipped writeback
This commit fixes an issue where shmem folios are left locked indefinitely
when writeback is skipped. It unlocks folios when they are redirtied or when
shmem_write_folio returns AOP_WRITEPAGE_ACTIVATE.
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index ef94401662955..e7b18f7f9644c 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -322,10 +322,16 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
> * as normal.
> */
> while ((folio = writeback_iter(mapping, &wbc, folio, &error))) {
[Severity: High]
This isn't a bug introduced by this patch, but does the hardcoded limit on
wbc.nr_to_write here cause the shrinker to severely under-reclaim?
In drivers/gpu/drm/i915/gem/i915_gem_shmem.c:__shmem_writeback(), the size
parameter is completely ignored and the writeback_control is initialized
earlier in the function with:
struct writeback_control wbc = {
.sync_mode = WB_SYNC_NONE,
.nr_to_write = SWAP_CLUSTER_MAX,
...
};
Because of this, writeback_iter() will terminate after 32 pages (128KB).
However, when the system is under memory pressure and i915_gem_shrinker_scan()
delegates to i915_gem_shrink(), try_to_writeback() eventually reaches
__shmem_writeback().
i915_gem_shrink() assumes the entire object was successfully written back
and increments its freed count by the full object size. If the object is
large, the mm subsystem is misled into thinking massive amounts of memory
were freed when only 128KB actually was. This could degrade memory reclaim
under pressure and lead to system stalls or OOMs.
Should the writeback limit respect the requested size parameter instead of
being hardcoded to SWAP_CLUSTER_MAX?
> - if (folio_mapped(folio))
> + if (folio_mapped(folio)) {
> folio_redirty_for_writepage(&wbc, folio);
> - else
> + folio_unlock(folio);
> + } else {
> error = shmem_write_folio(folio);
> + if (error == AOP_WRITEPAGE_ACTIVATE) {
> + folio_unlock(folio);
> + error = 0;
> + }
> + }
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914105606.3997649-1-matthias.goergens@gmail.com?part=1
next prev parent reply other threads:[~2026-09-14 11:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 10:56 [PATCH] drm/i915: unlock shmem folios after skipped writeback Matthias Goergens
2026-09-14 11:15 ` sashiko-bot [this message]
2026-09-15 6:32 ` Matthias Goergens
2026-09-15 18:38 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
2026-09-23 7:03 ` [PATCH] " Matthias Goergens
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=20260914111511.648711F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthias.goergens@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox