intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shuicheng Lin" <shuicheng.lin@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 1/2] drm/xe/shrinker: Do not abort the walk on unshrinkable bos
Date: Tue, 01 Sep 2026 03:42:50 +0000	[thread overview]
Message-ID: <20260901034250.DEFCA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901033153.219481-2-shuicheng.lin@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Skipping unshrinkable BOs with `continue` without incrementing the `scanned` counter creates an unbounded traversal of the LRU list.

Pre-existing issues:
- [High] The caller `xe_shrinker_walk()` drops all pages freed in earlier escalation passes if a subsequent pass fails, causing lost reclaim accounting.
--

commit 81485d1f41620f8c926444a5582c744bb5207d71
Author: Shuicheng Lin <shuicheng.lin@intel.com>

drm/xe/shrinker: Do not abort the walk on unshrinkable bos

The commit makes the shrinker skip over unshrinkable BOs instead of aborting
the walk, and attempts to fix the lost reclaim count when returning an error.

> diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
> index 83374cd576608..953a911b51b30 100644
> --- a/drivers/gpu/drm/xe/xe_shrinker.c
> +++ b/drivers/gpu/drm/xe/xe_shrinker.c
> @@ -79,8 +79,10 @@ static s64 __xe_shrinker_walk(struct xe_device *xe,
>  				continue;
>  
>  			lret = xe_bo_shrink(ctx, ttm_bo, flags, scanned);
> +			if (lret == -EBUSY)
> +				continue;

[Severity: High]
Does skipping unshrinkable BOs here create an unbounded traversal of the LRU
list? 

If xe_bo_shrink() returns -EBUSY, the scanned counter is not incremented.
This bypasses the termination check, allowing the loop to endlessly traverse
the BO LRU list when it contains many pinned or unshrinkable buffers.

This is a pre-existing issue in the same loop, but the
ttm_bo_shrink_suitable() check also fails to increment the scanned counter:

			if (!ttm_bo_shrink_suitable(ttm_bo, ctx))
				continue;

>  			if (lret < 0)
> -				return lret;
> +				return freed ? freed : lret;

[Severity: High]
This isn't a bug introduced by this patch, but is there a similar lost reclaim
accounting issue in the caller xe_shrinker_walk()?

When xe_shrinker_walk() transitions to the second pass (non-idle objects), an
error drops the pages successfully freed in the first pass:

	freed = lret;
	if (!ctx->no_wait_gpu) {
		lret = __xe_shrinker_walk(xe, ctx, save_flags, to_scan, scanned);
		if (lret < 0)
			return lret;

Could this cause the memory management core to receive a report of 0 pages
freed, incorrectly assuming reclaim is failing and triggering premature OOM?

>  
>  			freed += lret;
>  			if (*scanned >= to_scan)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901033153.219481-1-shuicheng.lin@intel.com?part=1

  reply	other threads:[~2026-09-01  3:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  3:31 [PATCH v4 0/2] drm/xe/shrinker: Runtime PM and walk termination fixes Shuicheng Lin
2026-09-01  3:31 ` [PATCH v4 1/2] drm/xe/shrinker: Do not abort the walk on unshrinkable bos Shuicheng Lin
2026-09-01  3:42   ` sashiko-bot [this message]
2026-09-01  3:31 ` [PATCH v4 2/2] drm/xe/shrinker: Take a runtime PM ref before shrinking non-system memory Shuicheng Lin
2026-09-01  3:38 ` ✗ CI.checkpatch: warning for drm/xe/shrinker: Runtime PM and walk termination fixes Patchwork
2026-09-01  3:40 ` ✓ CI.KUnit: success " Patchwork
2026-09-01  4:16 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-01  5:21 ` ✗ 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=20260901034250.DEFCA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shuicheng.lin@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;
as well as URLs for NNTP newsgroup(s).