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 BC14C606A32D for ; Wed, 2 Dec 2026 23:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=a8kA0x08 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A735112638; Wed, 2 Dec 2026 23:53:04 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id B44B4112638; Wed, 2 Dec 2026 23:52:58 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 39D8061754; Wed, 2 Dec 2026 23:52:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF5AE1F00923; Wed, 2 Dec 2026 23:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796255577; bh=GSZWgmZ2ozZQxCXr01f7tlmhHnveLMYLXgF0dIJHqt8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=a8kA0x0857qHbkrzYE6dhDILYhLUE5K7pGPGuPi3oErV8wC71MaOorJXbuwqDpNxa YZDXGYuJ1cIoDhEbmKIHiBxREfQLmoQVEkonzp7CunrwXbSBk9gUmR1VNeSpJqfktu kjj3FRcH8Z9S0NMvXCOuOMVxZFMlvWQQ8yG1tdIOVSppRG3s0/yPTYcQUCSWS9ja+j 2oasPeikWguZTwfgowcduadcbbPlsLn9XMzUCxA+JxO+8jiHNEp3YVlOTF17K2URr3 TRNuv9LWT2/lcHHgU1Z1MF69sVxm1n1cRPnIOHOrW+qwXlZYrZ3Z9gyZI3WCrlIf5x 4GpbQ1M/dLNXw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 17/36] drm/xe: Skip self-copies for borrowed pages on defrag moves To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261202233323.3743190-18-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-18-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 23:52:57 +0000 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: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/xe: WARN_ON and -EINVAL in __xe_migrate_copy() on extra_pages-only defrag - [Low] drm/xe: commit message claims stub fence on no-op copy in __xe_migrate_copy() -- commit ce7de21d385e57fce79126c867241da7e3be2512 Author: Matthew Brost drm/xe: Skip self-copies for borrowed pages on defrag moves This commit skips GPU data blits on the defragmentation data pass for pages that the new ttm_tt borrowed directly from the old ttm_tt. > When an entire L0 chunk turns out to be borrowed, skip it outright: no > batch buffer is allocated and no GPU commands are issued, the cursors are > just advanced past the chunk. If every chunk of the move is borrowed the > copy is a complete no-op, so hand back a signaled stub fence. [Severity: Low] This isn't a bug, but the commit message still says a signaled stub fence is returned when every chunk is borrowed, whereas v5 changed __xe_migrate_copy() to warn on !fence and return ERR_PTR(-EINVAL). > diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migr= ate.c > index 71192fbd722d6..5b40405aaba90 100644 > --- a/drivers/gpu/drm/xe/xe_migrate.c > +++ b/drivers/gpu/drm/xe/xe_migrate.c [ ... ] > @@ -1442,9 +1513,30 @@ static struct dma_fence *__xe_migrate_copy(struct = xe_migrate *m, > xe_assert(xe, IS_ALIGNED(ccs_it.start, PAGE_SIZE)); > } > =20 > - /* Add copy commands size here */ > + /* > + * Add copy commands size here. On the defrag data pass the blit > + * is split into one command per run of non-borrowed pages, so > + * size for the number of runs actually needed. > + */ > + if (skip_borrowed) > + ndata_blits =3D emit_copy_chunks(gt, NULL, 0, 0, src_L0, > + src_tt, dst_tt, start_page); > + > + /* > + * If every page in this chunk was borrowed there is nothing to > + * copy: don't build a batch or issue any GPU commands, just > + * advance the cursors past the chunk. The non-vram tt cursors > + * would otherwise be advanced by emit_pte(). > + */ > + if (skip_borrowed && !ndata_blits) { > + xe_res_next(&src_it, src_L0); > + xe_res_next(&dst_it, src_L0); > + size -=3D src_L0; > + continue; > + } [ ... ] > @@ -1529,6 +1624,15 @@ static struct dma_fence *__xe_migrate_copy(struct = xe_migrate *m, > return ERR_PTR(err); > } > =20 > + /* > + * A defrag move always (re)allocates at least one chunk (TTM fails a > + * zero-progress defrag move), so at least one page differs and a job > + * carrying the resv dependencies is always emitted. A signaled stub > + * here would let the old tt be torn down under in-flight GPU work. > + */ > + if (XE_WARN_ON(!fence)) > + return ERR_PTR(-EINVAL); > + > return fence; > } [Severity: Medium] Can __xe_migrate_copy() hit XE_WARN_ON(!fence) and fail the move with -EINVAL when a defrag pass only reallocates pages in the trailing CCS extra_pages region? When xe_bo_needs_ccs_pages(bo) is true, xe_ttm_tt_create() appends extra_pages beyond xe_bo_size(bo) >> PAGE_SHIFT to tt->num_pages, and the TTM pool allocator defragments across the full [0, tt->num_pages) array. If all data chunks in [0, xe_bo_size(bo)) are already at beneficial order (either initially or after earlier budget-limited defrag passes) and only a beneficial-order chunk in the trailing extra_pages region is upgraded, TTM's defrag allocation succeeds while borrowing every data page. Because __xe_migrate_copy() only iterates over size =3D xe_bo_size(src_bo), emit_copy_chunks() returns 0 for every pass and the loop finishes with fence =3D=3D NULL, triggering the warning and leaving the BO on the defrag list to fail again on subsequent passes. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202233323.3743= 190-1-matthew.brost@intel.com?part=3D17