Intel-XE Archive on lore.kernel.org
 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 v6 2/2] drm/xe/shrinker: Take a runtime PM ref before shrinking non-system memory
Date: Fri, 04 Sep 2026 22:05:21 +0000	[thread overview]
Message-ID: <20260904220521.8D57B1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904215049.543535-3-shuicheng.lin@intel.com>

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

Pre-existing issues:
- [High] Premature termination of shrinker scan due to treating -EBUSY on individual BOs as a fatal error.
--

commit b598ba1dc223459e465dd240779b658d7d771f73
Author: Shuicheng Lin <shuicheng.lin@intel.com>
drm/xe/shrinker: Take a runtime PM ref before shrinking non-system memory

This commit takes a runtime PM reference before walking memory types other
than XE_PL_SYSTEM in the shrinker to prevent GPU page table zap from
tripping an assert when the device is suspended. It reuses the shrinker's
existing acquire path to resume the device directly or queues a worker if
needed.

> diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
> index 89445cd202380..13f49ac873b4b 100644
> --- a/drivers/gpu/drm/xe/xe_shrinker.c
> +++ b/drivers/gpu/drm/xe/xe_shrinker.c

[ ... ]

> @@ -75,23 +95,36 @@ static int __xe_shrinker_walk(struct xe_device *xe,
>  		if (!man || !man->use_tt)
>  			continue;
>  
> +		if (mem_type != XE_PL_SYSTEM && !rpm &&
> +		    xe_device_is_l2_flush_optimized(xe)) {
> +			if (!__xe_shrinker_runtime_pm_get(shrinker))
> +				break;
> +			rpm = true;
> +		}
> +
>  		ttm_bo_lru_for_each_reserved_guarded(&curs, man, &arg, ttm_bo) {
>  			if (!ttm_bo_shrink_suitable(ttm_bo, ctx))
>  				continue;
>  
>  			lret = xe_bo_shrink(ctx, ttm_bo, flags, scanned);
> -			if (lret < 0)
> -				return lret;
> +			if (lret < 0) {
> +				ret = lret;
> +				goto out;
> +			}

[Severity: High]
This isn't a bug introduced by this patch, but it carries forward a severe
pre-existing issue in the new error path. Does treating non-fatal
object-level errors as scan-fatal errors prematurely abort the memory
reclaim process?

When the system is under memory pressure, __xe_shrinker_walk() iterates
over the BO LRU list in drivers/gpu/drm/xe/xe_shrinker.c. If it encounters
a BO that is not purgeable or not eviction-valuable, xe_bo_shrink()
correctly returns -EBUSY for that object:

drivers/gpu/drm/xe/xe_bo.c:xe_bo_shrink() {
    if (!(tt->page_flags & TTM_TT_FLAG_EXTERNAL_MAPPABLE) ||
        (flags.purge && !xe_tt->purgeable))
        return -EBUSY;

    if (!xe_bo_eviction_valuable(bo, &place))
        return -EBUSY;
    ...
}

Because lret < 0 triggers an immediate loop break (now via the goto out
statement), encountering a single unshrinkable BO permanently halts the
shrinker scan for that memory type. This prevents the shrinker from
reaching valid evictable objects further down the LRU list, effectively
disabling memory reclaim. Should this loop skip the busy BO and continue
instead of aborting the entire scan?

>  			*freed += lret;
>  			if (*scanned >= to_scan)
> -				break;
> +				goto out;
>  		}
>  		/* Trylocks should never error, just fail. */
>  		xe_assert(xe, !IS_ERR(ttm_bo));
>  	}
>  
> -	return 0;
> +out:
> +	if (rpm)
> +		xe_pm_runtime_put(xe);
> +
> +	return ret;
>  }

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

  reply	other threads:[~2026-09-04 22:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 21:50 [PATCH v6 0/2] drm/xe/shrinker: Runtime PM reference for non-system memory Shuicheng Lin
2026-09-04 21:50 ` [PATCH v6 1/2] drm/xe/shrinker: Return the freed page count through a parameter Shuicheng Lin
2026-09-04 21:59   ` sashiko-bot
2026-09-09 12:58   ` Thomas Hellström
2026-09-04 21:50 ` [PATCH v6 2/2] drm/xe/shrinker: Take a runtime PM ref before shrinking non-system memory Shuicheng Lin
2026-09-04 22:05   ` sashiko-bot [this message]
2026-09-07  8:23   ` Thomas Hellström
2026-09-04 22:10 ` ✓ CI.KUnit: success for drm/xe/shrinker: Runtime PM reference for " Patchwork
2026-09-04 23:05 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-05  4:15 ` ✓ Xe.CI.FULL: " 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=20260904220521.8D57B1F00A3D@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