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 EA559606A322 for ; Wed, 2 Dec 2026 23:58:05 +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=U5pGwRca Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45B1111269B; Wed, 2 Dec 2026 23:58:00 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F1F211269B; Wed, 2 Dec 2026 23:57:54 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id ED4D8437C9; Wed, 2 Dec 2026 23:57:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3A281F000C1; Wed, 2 Dec 2026 23:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796255873; bh=j+nfSry/HmPTXsP1D+Z/xKeQbyGTmMaFBiTFgIlrufw=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=U5pGwRcaoX45x6DyjeXrMatNSdSlYyDdzWYZlnFau7x7Hzd0E7qeMQZGd0Q3DhFyk Rpv0AsdfDqEpeu4xT3nwKJAad759lCfSU8PRyNQPpys0mfzy8sXAr0JD/fmAekg82r sVy6RobmMZzahHSpSpXRV6vvciq3LQYn2qQEhOFpTTmeR0YZo0085uUbEhPshYNA+k V4NeG1Qo7DhnYD/piK9QqamA7F7fPxXrlQB8ifdeeMVGCP9GVAd45rmN2RGApRZxiK fIqCgyWmeYaIxpDOqVXbyu4AHAeHUId1zOOdnRhkxe5X3c21/i/jjNS8j15pj7CtrZ fQ90u6C+e0Zeg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 10/36] drm/ttm: Preallocate beneficial-order defrag pages outside the lock To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261202233323.3743190-11-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-11-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 23:57:53 +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 1 potential issue to consider: - [Low] drm/ttm: stale beneficial-order failure flag on resumed restore in ttm_pool_restore_and_alloc() -- commit 5e2ee65385b61ac88536ccf836b08b653cbf5979 Author: Matthew Brost drm/ttm: Preallocate beneficial-order defrag pages outside the lock This commit adds out-of-lock preallocation of beneficial-order pages for TTM defragmentation moves and records the number of sub-optimal pages on each ttm_tt at populate time. > diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_poo= l.c > index 79538d776dde3..fa76f880d5632 100644 > --- a/drivers/gpu/drm/ttm/ttm_pool.c > +++ b/drivers/gpu/drm/ttm/ttm_pool.c [ ... ] > @@ -1384,7 +1628,7 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *poo= l, struct ttm_tt *tt, > gfp_t gfp =3D GFP_KERNEL | __GFP_NOWARN; > =20 > tt->page_flags &=3D ~TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED; > - ttm_pool_alloc_state_init(tt, &alloc); > + ttm_pool_alloc_state_init(pool, tt, &alloc); > if (ctx->gfp_retry_mayfail) > gfp |=3D __GFP_RETRY_MAYFAIL; > =20 > @@ -1414,11 +1658,16 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *p= ool, struct ttm_tt *tt, > kfree(tt->restore); > tt->restore =3D NULL; > =20 > + tt->nr_suboptimal_pages =3D alloc.nr_suboptimal_pages; > return 0; > } > } > =20 > - return __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); > + ret =3D __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); > + if (!ret) > + tt->nr_suboptimal_pages =3D alloc.nr_suboptimal_pages; > + > + return ret; > } [Severity: Low] Can a resumed restore finish with TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED set on tt->page_flags while tt->nr_suboptimal_pages is 0? During a restore, ttm_pool_iter_lower_order() sets TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED directly on tt->page_flags before the lower-order fallback chunk is allocated, restored, and committed to restore->snapshot_alloc. If ttm_pool_restore_commit() is then interrupted at restore->restored_pages =3D=3D 0, it frees the uncommitted fallback page without advancing restore->snapshot_alloc: drivers/gpu/drm/ttm/ttm_pool.c:ttm_pool_restore_commit() { ... if (ret) { if (!restore->restored_pages) { dma_addr_t *dma_addr =3D alloc->dma_addr ? &restore->first_dma : NULL; ttm_pool_unmap_and_free(restore->pool, restore->alloced_page, dma_addr, restore->page_caching); restore->restored_pages =3D nr; } return ret; } ... } When ttm_pool_restore_and_alloc() is called again to resume, it reloads restore->snapshot_alloc without clearing TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED. If the resumed pass then succeeds at the beneficial order, the restore completes with TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED still set and tt->nr_suboptimal_pages =3D=3D 0, causing drivers to repeatedly queue an already optimal BO for defragmentation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202233323.3743= 190-1-matthew.brost@intel.com?part=3D10