From: Shuicheng Lin <shuicheng.lin@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Shuicheng Lin" <shuicheng.lin@intel.com>,
Sashiko <sashiko-bot@kernel.org>,
stable@vger.kernel.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Matthew Brost" <matthew.brost@intel.com>
Subject: [PATCH v5 1/2] drm/xe/shrinker: Do not discard freed pages on error
Date: Tue, 1 Sep 2026 17:30:58 +0000 [thread overview]
Message-ID: <20260901173059.455469-2-shuicheng.lin@intel.com> (raw)
In-Reply-To: <20260901173059.455469-1-shuicheng.lin@intel.com>
__xe_shrinker_walk() and xe_shrinker_walk() both return the error in
place of the pages they have already freed. xe_shrinker_scan() only
accumulates non-negative returns, so those pages are never reported,
while *scanned is updated by pointer and does count them. The shrinker
then tells mm that it scanned without freeing, which skews the reclaim
accounting away from it.
Report what was freed when there is something to report, and the error
only when there is not.
v2: drop EBUSY check and add more return check. (Sashiko)
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: 00c8efc3180f ("drm/xe: Add a shrinker for xe bos")
Assisted-by: Claude:claude-opus-5
Cc: stable@vger.kernel.org
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
drivers/gpu/drm/xe/xe_shrinker.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
index 83374cd57660..7f40153911ff 100644
--- a/drivers/gpu/drm/xe/xe_shrinker.c
+++ b/drivers/gpu/drm/xe/xe_shrinker.c
@@ -80,7 +80,7 @@ static s64 __xe_shrinker_walk(struct xe_device *xe,
lret = xe_bo_shrink(ctx, ttm_bo, flags, scanned);
if (lret < 0)
- return lret;
+ return freed ? freed : lret;
freed += lret;
if (*scanned >= to_scan)
@@ -119,7 +119,7 @@ static s64 xe_shrinker_walk(struct xe_device *xe,
if (!ctx->no_wait_gpu) {
lret = __xe_shrinker_walk(xe, ctx, save_flags, to_scan, scanned);
if (lret < 0)
- return lret;
+ return freed ? freed : lret;
freed += lret;
if (*scanned >= to_scan)
return freed;
@@ -128,7 +128,7 @@ static s64 xe_shrinker_walk(struct xe_device *xe,
if (flags.writeback) {
lret = __xe_shrinker_walk(xe, ctx, flags, to_scan, scanned);
if (lret < 0)
- return lret;
+ return freed ? freed : lret;
freed += lret;
}
--
2.43.0
next prev parent reply other threads:[~2026-09-01 17:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 17:30 [PATCH v5 0/2] drm/xe/shrinker: Runtime PM and freed page accounting fixes Shuicheng Lin
2026-09-01 17:30 ` Shuicheng Lin [this message]
2026-09-01 17:42 ` [PATCH v5 1/2] drm/xe/shrinker: Do not discard freed pages on error sashiko-bot
2026-09-01 17:30 ` [PATCH v5 2/2] drm/xe/shrinker: Take a runtime PM ref before shrinking non-system memory Shuicheng Lin
2026-09-01 17:41 ` sashiko-bot
2026-09-01 17:37 ` ✗ CI.checkpatch: warning for drm/xe/shrinker: Runtime PM and freed page accounting fixes Patchwork
2026-09-01 17:39 ` ✓ CI.KUnit: success " Patchwork
2026-09-01 18:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-01 20:12 ` ✗ Xe.CI.FULL: failure " Patchwork
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=20260901173059.455469-2-shuicheng.lin@intel.com \
--to=shuicheng.lin@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
/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