Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Natalie Vock" <nat@pixelcluster.dev>,
	"Arun Pravin" <arunpravin.paneerselvam@amd.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Niranjana Vishwanathapura" <niranjana.vishwanathapura@intel.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 0/4] drm/ttm, drm/xe: Support partially backed-up ttm_tts
Date: Wed,  4 Nov 2026 21:13:27 +0100	[thread overview]
Message-ID: <20261104201331.2462-1-thomas.hellstrom@linux.intel.com> (raw)

The TTM shrinker backs up a ttm_tt page by page, and can stop part way
through, for example on an allocation failure. A failed restore can
likewise leave some pages resident and some backed up. The ttm_tt has no
way to represent such a partially backed-up state, so its status and the
driver's shrinker accounting can become inconsistent.

This series introduces TTM_TT_FLAG_PARTIAL, which allows a tt to be
partially backed up, keeping track of the pages that were already backed
up and the pages that are still resident. Xe shrinker accounting is
converted to track the number of remaining resident pages so that
partial tts are accounted correctly.

Patch 1 stops marking backed-up shmem folios accessed.
Patch 2 is a pure refactor of the Xe shrinker account helpers.
Patch 3 introduces TTM_TT_FLAG_PARTIAL and the matching Xe accounting.
Patch 4 gates reserve-dipping backup retries on may_writeback.

Note that patch 4 may increase the number of partially backed-up
ttm_tts, since a backup that would need to dip into the kernel reserves
is now aborted when writeback isn't allowed, keeping the progress made
so far. This makes the partial tt handling of patch 3 more important.

Testing:
- W=1 build, checkpatch and kernel-doc are clean.
- TTM and Xe KUnit tests pass.
- The partial backup and restore paths are exercised by the
  shrink-fault-inject* subtests of the xe_bo_shrink IGT test, posted
  separately, using the TTM backup_fault_inject debugfs attribute. They
  need CONFIG_FAULT_INJECTION and CONFIG_FAULT_INJECTION_DEBUG_FS. The
  may_writeback retry in patch 4 is only hit statistically by that test.

IGT test: https://patchwork.freedesktop.org/series/176563/

Test-with: 20261021123315.10033-1-thomas.hellstrom@linux.intel.com

AI tool use: an AI coding assistant was used for review and for
drafting parts of the implementation and commit messages. The author has
reviewed and takes responsibility for all of the changes.

Thomas Hellström (4):
  drm/ttm: Don't mark backed-up shmem folios accessed
  drm/xe/bo: Pass page and tt counts to the shrinker account helpers
  drm/ttm, drm/xe: Introduce TTM_TT_FLAG_PARTIAL for partially backed-up
    tts
  drm/ttm, drm/xe: Gate reserve-dipping backup retries on may_writeback

 drivers/gpu/drm/ttm/ttm_backup.c        |   1 -
 drivers/gpu/drm/ttm/ttm_bo.c            |   5 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c       |   9 +-
 drivers/gpu/drm/ttm/ttm_pool.c          | 175 +++++++++++++++++++++---
 drivers/gpu/drm/ttm/ttm_pool_internal.h |   2 +
 drivers/gpu/drm/ttm/ttm_tt.c            |  36 ++++-
 drivers/gpu/drm/xe/tests/xe_bo.c        |   6 +-
 drivers/gpu/drm/xe/xe_bo.c              | 110 ++++++++++-----
 drivers/gpu/drm/xe/xe_bo.h              |   9 +-
 drivers/gpu/drm/xe/xe_shrinker.c        |  39 +++++-
 include/drm/ttm/ttm_bo.h                |   9 +-
 include/drm/ttm/ttm_tt.h                |  58 ++++++--
 12 files changed, 371 insertions(+), 88 deletions(-)

-- 
2.56.0


             reply	other threads:[~2026-11-04 20:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 20:13 Thomas Hellström [this message]
2026-11-04 20:13 ` [PATCH 1/4] drm/ttm: Don't mark backed-up shmem folios accessed Thomas Hellström
2026-11-04 20:13 ` [PATCH 2/4] drm/xe/bo: Pass page and tt counts to the shrinker account helpers Thomas Hellström
2026-11-04 20:13 ` [PATCH 3/4] drm/ttm, drm/xe: Introduce TTM_TT_FLAG_PARTIAL for partially backed-up tts Thomas Hellström
2026-11-04 20:47   ` sashiko-bot
2026-11-04 20:13 ` [PATCH 4/4] drm/ttm, drm/xe: Gate reserve-dipping backup retries on may_writeback Thomas Hellström
2026-11-04 20:41   ` sashiko-bot
2026-11-04 20:23 ` ✓ CI.KUnit: success for drm/ttm, drm/xe: Support partially backed-up ttm_tts Patchwork
2026-11-04 20:57 ` ✓ Xe.CI.BAT: " 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=20261104201331.2462-1-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=nat@pixelcluster.dev \
    --cc=niranjana.vishwanathapura@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