Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C67F7606A329 for ; Tue, 1 Dec 2026 23:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=c7LTX9pM Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2DBC10FE3A; Tue, 1 Dec 2026 23:50:10 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 48D6210FE30; Tue, 1 Dec 2026 23:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796169003; x=1827705003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xHHJ+K8cdmKbKeb+peuvJ905rHnQRVnkPLEcgKl8VtE=; b=c7LTX9pMiPpHTJw5Ay00nRLAGG6TlfatOvfeP/Jpg+ley9elnIt75ULR Ai5UgINgEuigjeGig27X+NJebGXizY8P5OMp0xNlYa/c0EOOtNZ11hqvP MO0ZYq0JBgf8JEzanQYsCNMq+PRBRWeVQ98rqMvGiGgDPFYYtq5CoaEJ9 yPNqrryzcCMvGtApSIfOK3xSEFsqc1WHQt0F6OcWceMEmAiVkkGvhXQq4 YggCz+4pZ030pQCqhZR7QaZHQkPzMTgf+FTcAb1G97pH8e96/Knh4vY3r 4yEnrilR3aUSg1vRCxW4DaCV4RkNfYxZAqIJh42eTaoMm3L1dBHMjXxy7 g==; X-CSE-ConnectionGUID: YOPInbPDQf2YX5MjsR4Uyw== X-CSE-MsgGUID: p7Pyf7LcRR2vbpB5mZQmow== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4977595" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="4977595" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 15:49:35 -0800 X-CSE-ConnectionGUID: V6UbtHBTQ3CgiK9SPNkcqQ== X-CSE-MsgGUID: NcUe6lqsQbuXT/wus+ioeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13920005" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 15:49:35 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Natalie Vock , Arun Pravin Subject: [PATCH v4 31/33] drm/xe: Grow the USM batch pool to 2M and map it via a single PDE Date: Tue, 1 Dec 2026 15:49:13 -0800 Message-Id: <20261201234915.3305331-32-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261201234915.3305331-1-matthew.brost@intel.com> References: <20261201234915.3305331-1-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The defrag copy path submits its migration batches from the USM batch pool. When the pool is small, xe_bb_new() backs up in the suballocator waiting for prior migrate batches to retire, and that stall happens while the BO reservation lock is held during the move. Traces of a 32MB defrag move showed the entire ~37ms lock hold sitting inside xe_migrate_copy_*() at xe_bb_new(), i.e. pool backpressure rather than actual copy time. Grow the USM batch pool from 512K (integrated) / 1M (DGFX) to a uniform 2M to give the migrate engine enough in-flight batch space to avoid this backpressure. On integrated (non-DGFX) the pool is mapped into the migrate VM through the shared level-0 pagetable alongside the 1M kernel batch pool. A full 2M needs 512 PTEs and no longer fits in that shared table's 2M window. Instead, map the USM pool through a dedicated level-0 pagetable (reusing an otherwise unused pt_bo page, as the vram identity map pages are only consumed on DGFX) and point a single reserved 2M PDE at it, mirroring the large_page_copy reservation. DGFX is unaffected as it reaches the pool through the vram identity map. Cc: Natalie Vock Cc: Arun Pravin Assisted-by: LLM Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_gt.c | 4 +--- drivers/gpu/drm/xe/xe_migrate.c | 34 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c index 7eacbe950ccd..7fb89bb5df75 100644 --- a/drivers/gpu/drm/xe/xe_gt.c +++ b/drivers/gpu/drm/xe/xe_gt.c @@ -660,10 +660,8 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt) * USM has its only SA pool to non-block behind user operations */ if (gt_to_xe(gt)->info.has_usm) { - struct xe_device *xe = gt_to_xe(gt); - gt->usm.bb_pool = xe_sa_bo_manager_init(gt_to_tile(gt), - IS_DGFX(xe) ? SZ_1M : SZ_512K, 16); + SZ_2M, 16); if (IS_ERR(gt->usm.bb_pool)) return PTR_ERR(gt->usm.bb_pool); } diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c index 8cb4a8c182ec..e349fbc63189 100644 --- a/drivers/gpu/drm/xe/xe_migrate.c +++ b/drivers/gpu/drm/xe/xe_migrate.c @@ -505,22 +505,42 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m, level++; } if (xe->info.has_usm) { + u64 usm_pt_ofs; + u32 usm_pde_slot, usm_pte; + xe_tile_assert(tile, xe_bo_size(batch) == SZ_1M); batch = tile->primary_gt->usm.bb_pool->bo; - m->usm_batch_base_ofs = m->batch_base_ofs + SZ_1M; - xe_tile_assert(tile, xe_bo_size(batch) == SZ_512K); + xe_tile_assert(tile, xe_bo_size(batch) == SZ_2M); - for (i = 0; i < xe_bo_size(batch); + /* + * The usm batch pool is a full 2M and no longer fits in + * the shared level-0 pagetable alongside the kernel + * batch pool. Map it through a dedicated level-0 + * pagetable (reusing an otherwise unused pt_bo page, as + * the vram identity map pages are only consumed on + * DGFX) and point a single reserved 2M PDE at it, + * mirroring the large_page_copy reservation below. + */ + usm_pt_ofs = xe_bo_size(bo) - 2 * XE_PAGE_SIZE; + for (i = 0, usm_pte = 0; i < xe_bo_size(batch); i += vm->flags & XE_VM_FLAG_64K ? XE_64K_PAGE_SIZE : - XE_PAGE_SIZE) { + XE_PAGE_SIZE, usm_pte++) { entry = vm->pt_ops->pte_encode_bo(batch, i, pat_index, 0); - xe_map_wr(xe, &bo->vmap, map_ofs + level * 8, u64, - entry); - level++; + xe_map_wr(xe, &bo->vmap, + usm_pt_ofs + usm_pte * 8, u64, entry); } + + usm_pde_slot = NUM_PT_SLOTS - 1; + xe_tile_assert(tile, + usm_pde_slot > map_ofs / XE_PAGE_SIZE); + entry = vm->pt_ops->pde_encode_bo(bo, usm_pt_ofs); + xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE + + usm_pde_slot * 8, u64, entry); + m->usm_batch_base_ofs = (u64)usm_pde_slot << + xe_pt_shift(1); } } else { u64 batch_addr = xe_bo_addr(batch, 0, XE_PAGE_SIZE); -- 2.34.1