public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Carlos Santa" <carlos.santa@intel.com>,
	"Matthew Auld" <matthew.auld@intel.com>
Subject: [PATCH v2 5/5] drm/xe: Avoid shrinker reclaim from kswapd under fragmentation
Date: Wed, 22 Apr 2026 22:56:56 -0700	[thread overview]
Message-ID: <20260423055656.1696379-6-matthew.brost@intel.com> (raw)
In-Reply-To: <20260423055656.1696379-1-matthew.brost@intel.com>

When the Xe shrinker is invoked from kswapd, a large amount of free
memory in usable zones relative to the high watermark is a strong
signal that reclaim is being driven by fragmentation rather than true
memory pressure.

In this case, shrinking Xe memory is unlikely to help kswapd make
forward progress. Instead it can evict active GPU memory despite the
system still having substantial free memory, increasing residency churn
and reducing GPU forward progress.

Detect this case and bail out early from the Xe shrinker when running in
kswapd and any usable zone has more than 2x its high watermark free.

Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Carlos Santa <carlos.santa@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_shrinker.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
index 83374cd57660..e28e5e90c198 100644
--- a/drivers/gpu/drm/xe/xe_shrinker.c
+++ b/drivers/gpu/drm/xe/xe_shrinker.c
@@ -236,6 +236,9 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con
 	if (nr_scanned >= nr_to_scan || !can_backup)
 		goto out;
 
+	if (ttm_bo_shrink_kswap_fragmented(sc->nid))
+		goto out;
+
 	/* If we didn't wake before, try to do it now if needed. */
 	if (!runtime_pm)
 		runtime_pm = xe_shrinker_runtime_pm_get(shrinker, true, 0, can_backup);
-- 
2.34.1


  parent reply	other threads:[~2026-04-23  5:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23  5:56 [PATCH v2 0/5] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Matthew Brost
2026-04-23  5:56 ` [PATCH v2 1/5] mm: Introduce zone_appears_fragmented() Matthew Brost
2026-04-23  6:04   ` Balbir Singh
2026-04-23  6:16     ` Matthew Brost
2026-04-23  6:27       ` Matthew Brost
2026-04-23 10:27   ` David Hildenbrand (Arm)
2026-04-23 11:27     ` Thomas Hellström
2026-04-23 19:08       ` Matthew Brost
2026-04-23 22:21         ` Matthew Brost
2026-04-24  7:05           ` Thomas Hellström
2026-04-24  7:26             ` David Hildenbrand (Arm)
2026-04-30  2:47               ` Matthew Brost
2026-04-30  7:47                 ` Thomas Hellström
2026-04-30 16:34                   ` Matthew Brost
2026-04-30 19:59                     ` Thomas Hellström
2026-04-30 17:06                   ` Vlastimil Babka (SUSE)
2026-04-28  9:51   ` Andi Shyti
2026-04-28 10:05     ` Andi Shyti
2026-04-30  2:34       ` Matthew Brost
2026-04-30  2:37     ` Matthew Brost
2026-04-23  5:56 ` [PATCH v2 2/5] drm/ttm: Issue direct reclaim at beneficial_order Matthew Brost
2026-04-28  9:55   ` Andi Shyti
2026-04-23  5:56 ` [PATCH v2 3/5] drm/ttm: Introduce ttm_bo_shrink_kswap_fragmented() Matthew Brost
2026-04-28 10:07   ` Andi Shyti
2026-04-30  6:23     ` Matthew Brost
2026-04-30  7:39       ` Christian König
2026-04-23  5:56 ` [PATCH v2 4/5] drm/xe: Set TTM device beneficial_order to 9 (2M) Matthew Brost
2026-04-28 10:46   ` Andi Shyti
2026-04-23  5:56 ` Matthew Brost [this message]
2026-04-23  6:04 ` ✓ CI.KUnit: success for mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Patchwork
2026-04-23  6:53 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-23 17:30 ` ✗ 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=20260423055656.1696379-6-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=carlos.santa@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --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