From mboxrd@z Thu Jan 1 00:00:00 1970 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 5FA2B606A32C for ; Wed, 2 Dec 2026 23:59:56 +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=QSOgGZUk Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C51181126A1; Wed, 2 Dec 2026 23:59:50 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4E5B1126A3; Wed, 2 Dec 2026 23:59:43 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 69F8260CF1; Wed, 2 Dec 2026 23:59:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 986C51F000C1; Wed, 2 Dec 2026 23:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796255983; bh=pv5eGTzUcsbGnu9TCd3EalZwxDh4DcqHhtLzSyTMkPQ=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=QSOgGZUk+W4NZZPfe9+137DWbVHWTe7sZvYuLqh82Ftx3ZhzWimXxNDw/ymqUYB/t YptUvLjgtKivV1M9uvJW++WiWyDYnJm5v7NiTErX1j+TZN8LrQ5wjUFeOn04QWyNUY ZFGWxHIPQocmnq7OAzh2+E69Oi8yvjQgPwlY0oVPGq4C7sD8h1RW7ERxh6O08v4adp mbyOcXojeUuJsRUduhFbnehi+NdRDMaRtaVKPCmRS/i/0xOFNpEXFv6K2EZ8qoBZ/F wFBut2o3LaNUNR+LLYVTrTT6gReL3+FYNbbclL7hq5Vc1Fdw0BEUzCpWOwHKsfrhK1 RQcSCbBC5NxMg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 11/36] drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261202233323.3743190-12-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-12-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 23:59:42 +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=unavailable 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: - [Medium] drm/ttm: repeated empty-pool list_lru locking in ttm_pool_prealloc_fill_full() -- commit a9c3c46ffa013c41ec426391623e966b58881b75 Author: Matthew Brost drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() This commit adds ttm_pool_prealloc_fill_full() to preallocate the entire backing of a system-memory ttm_tt at mixed orders outside the dma-resv lock. > diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_poo= l.c > index fa76f880d5632..7b1736324f7e5 100644 > --- a/drivers/gpu/drm/ttm/ttm_pool.c > +++ b/drivers/gpu/drm/ttm/ttm_pool.c [ ... ] > +static struct page *ttm_pool_take_page(struct ttm_pool *pool, > + enum ttm_caching caching, > + unsigned int *order, gfp_t gfp, > + bool *need_caching, > + bool beneficial_reclaim_backoff) > +{ > + unsigned int beneficial =3D ttm_pool_beneficial_order(pool); > + struct ttm_pool_type *pt; > + struct page *p; > + > + *need_caching =3D false; > + > + if (IS_ENABLED(CONFIG_FAULT_INJECTION) && beneficial && > + *order >=3D beneficial && > + should_fail(&beneficial_order_fault_inject, 1)) { > + *order =3D beneficial; > + return NULL; > + } > + > + pt =3D ttm_pool_select_type(pool, caching, *order); > + if (pt) { > + p =3D ttm_pool_type_take(pt, ttm_pool_nid(pool)); > + if (p) > + return p; /* pool page already carries @caching */ > + } > + > + p =3D ttm_pool_alloc_page(pool, gfp, *order, beneficial_reclaim_backoff= ); > + if (!p) > + return NULL; > + > + /* Fresh system page is write-back; caller applies @caching in bulk. */ > + *need_caching =3D true; > + return p; > +} [ ... ] > +int ttm_pool_prealloc_fill_full(struct ttm_pool *pool, > + enum ttm_caching tt_caching, > + struct ttm_pool_prealloc *pp, > + unsigned int num_pages, > + bool beneficial_reclaim_backoff) > +{ [ ... ] > + while (remaining) { > + unsigned int order =3D min_t(unsigned int, highest, > + __fls(remaining)); > + bool need_caching; > + struct page *p; > + > + for (;;) { > + p =3D ttm_pool_take_page(pool, tt_caching, &order, gfp, > + &need_caching, > + beneficial_reclaim_backoff); > + if (p) > + break; > + if (!order) > + goto apply_caching; /* short fill */ > + /* > + * Genuine failure: retry one order down. A fault > + * injection lowered @order to the beneficial order > + * above, so this drops it below - landing on a > + * sub-optimal (defrag-worthy) chunk. > + */ > + order--; > + } [Severity: Medium] Should ttm_pool_prealloc_fill_full() stop probing the pool at the current order once ttm_pool_type_take() returns NULL, the way ttm_pool_iter_acquire_page() does with it->allow_pools? In the in-line allocator, once ttm_pool_type_take() misses at a given order, it->allow_pools is cleared until the allocator drops to a lower order. Here, ttm_pool_take_page() calls ttm_pool_type_take() on every iteration of the while (remaining) loop. On x86, ttm_write_combined and ttm_uncached use the global pool types, and ttm_pool_type_take() -> list_lru_walk_node() unconditionally acquires and releases the list_lru spinlock even when the list is empty. When the global WC or UC pool is empty and allocation falls back to order 0 (for instance when beneficial_reclaim_backoff skips reclaim at higher orders), preallocating a buffer object acquires and releases the global order-0 list_lru spinlock once per 4K page instead of once per order, contending across concurrent unlocked preallocations. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202233323.3743= 190-1-matthew.brost@intel.com?part=3D11