From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>
Subject: [PATCH v2 4/6] drm/xe/migrate: optimise chunk sizes for identity VRAM clears
Date: Fri, 27 Nov 2026 12:14:14 +0000 [thread overview]
Message-ID: <20261127-migrate-bb-optimise-v2-4-808d0d520ddb@intel.com> (raw)
In-Reply-To: <20261127-migrate-bb-optimise-v2-0-808d0d520ddb@intel.com>
xe_migrate_clear() currently clamps every clear pass to 8M. On platforms
with Xe2 blitter instructions and no separate CCS copy emission, VRAM
clears use the identity map without dynamic PTE updates and execute on
the dedicated migration engine, so clamping each pass to 8M splits
a 1G+ clear into 100+ jobs. 1G VRAM pages look quite normal in real
workloads like llama.py with even a small model.
It looks like the 8M limit comes from wanting a ~1ms preemption
granularity, and dates back to i915. But consider:
1. Xe has kernel reserved BCS engine just for migrations on newer hw,
so no need to duke it out with userspace jobs. Further, we now also
dropped the GPU VM_BIND path, so there is now only a single migration
queue, so the ~1ms preemption granularity is maybe not a big deal
anymore.
2. It does not take ~1ms to clear 8M (single MEM_SET) of VRAM through
the identity map. Currently we just lump everything in the same
bucket, even though we have VRAM clearing with identity, VRAM
clearing with PTE emit, and then copying between VRAM and system
memory, which will have different characteristics and performance.
Applying the same 8M limit everywhere seems overly cautious.
With that be more optimistic and bump the fast path VRAM clearing
through identity map to 128M per single MEM_SET instruction. This still
only takes up to around < ~2ms, or < ~1ms if boosted. For very large
clears, this massively lowers the number of GPU jobs, reducing pressure
on the bb pool and as a bonus gives slightly lower CPU/GPU overhead.
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/9644
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
drivers/gpu/drm/xe/xe_migrate.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index 31392e7957ea..f34b741bbc77 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -261,6 +261,7 @@ struct xe_migrate {
#define MAX_PREEMPTDISABLE_TRANSFER SZ_8M /* Around 1ms. */
#define MAX_CCS_LIMITED_TRANSFER SZ_4M /* XE_PAGE_SIZE * (FIELD_MAX(XE2_CCS_SIZE_MASK) + 1) */
+#define MAX_IDENTITY_CLEAR_TRANSFER SZ_128M
#define NUM_PT_SLOTS 48
#define LEVEL0_PAGE_TABLE_ENCODE_SIZE SZ_2M
#define MAX_NUM_PTE 512
@@ -2053,6 +2054,11 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
u32 avail_pts = max_mem_transfer_per_pass(xe) / LEVEL0_PAGE_TABLE_ENCODE_SIZE;
clear_L0 = xe_migrate_res_sizes(m, &src_it);
+ if (clear_vram && !xe_migrate_needs_ccs_emit(xe) &&
+ gt->info.has_xe2_blt_instructions &&
+ xe_migrate_allow_identity(clear_L0, &src_it))
+ clear_L0 = min_t(u64, MAX_IDENTITY_CLEAR_TRANSFER,
+ src_it.size);
/* Calculate final sizes and batch size.. */
pte_flags = clear_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0;
--
2.56.1
next prev parent reply other threads:[~2026-11-27 12:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 12:14 [PATCH v2 0/6] Interruptible bb wait + related bits Matthew Auld
2026-11-27 12:14 ` [PATCH v2 1/6] drm/xe/sa: allow callers to specify interruptible suballocator waits Matthew Auld
2026-11-27 12:14 ` [PATCH v2 2/6] drm/xe/migrate: plumb interruptible wait flag to clear and copy Matthew Auld
2026-11-27 12:14 ` [PATCH v2 3/6] drm/xe/migrate: avoid interruptible waits once passes are in flight Matthew Auld
2026-11-27 12:14 ` Matthew Auld [this message]
2026-11-27 12:14 ` [PATCH v2 5/6] drm/xe/bb: drop per-batch prefetch padding Matthew Auld
2026-11-27 12:33 ` sashiko-bot
2026-11-27 12:14 ` [PATCH v2 6/6] drm/xe/sa: remove unused shadow BO and two-step bb helpers Matthew Auld
2026-11-27 12:27 ` ✓ CI.KUnit: success for Interruptible bb wait + related bits (rev2) 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=20261127-migrate-bb-optimise-v2-4-808d0d520ddb@intel.com \
--to=matthew.auld@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@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