* [PATCH] drm/ttm/pool: Try harder for beneficial orders
@ 2026-06-17 2:22 Matthew Brost
2026-06-17 8:59 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Brost @ 2026-06-17 2:22 UTC (permalink / raw)
To: intel-xe, dri-devel
Cc: Christian Koenig, Huang Rui, Matthew Auld, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
linux-kernel, Thomas Hellström
When a driver specifies a beneficial order, TTM should make a reasonable
effort to allocate pages at that order.
Use __GFP_RETRY_MAYFAIL instead of __GFP_NORETRY when allocating at the
beneficial order. This allows reclaim to try harder before falling back to
smaller orders, at the cost of longer allocation setup time.
That tradeoff is acceptable for beneficial-order allocations: higher-order
backing pages can improve TLB hit rates and reduce the number of TLB
invalidations needed when moving memory.
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
Together with other Xe/core shrinker changes currently under development,
this change significantly improved performance under memory fragmentation
on PTL. In 3DMark Wild Life Extreme, performance improved by up to 120%
compared to the baseline fragmented-memory case. GravityMark also showed
approximately a 20% improvement under similar conditions.
---
drivers/gpu/drm/ttm/ttm_pool.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 9f0ab99eb289..682ae4f40424 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -168,6 +168,11 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
if (order && beneficial_order && order != beneficial_order)
gfp_flags &= ~__GFP_RECLAIM;
+ if (beneficial_order && order == beneficial_order) {
+ gfp_flags &= ~__GFP_NORETRY;
+ gfp_flags |= __GFP_RETRY_MAYFAIL;
+ }
+
if (!ttm_pool_uses_dma_alloc(pool)) {
p = alloc_pages_node(pool->nid, gfp_flags, order);
if (p) {
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] drm/ttm/pool: Try harder for beneficial orders
2026-06-17 2:22 [PATCH] drm/ttm/pool: Try harder for beneficial orders Matthew Brost
@ 2026-06-17 8:59 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-06-17 8:59 UTC (permalink / raw)
To: Matthew Brost, intel-xe, dri-devel
Cc: Huang Rui, Matthew Auld, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, linux-kernel,
Thomas Hellström
On 6/17/26 04:22, Matthew Brost wrote:
> When a driver specifies a beneficial order, TTM should make a reasonable
> effort to allocate pages at that order.
>
> Use __GFP_RETRY_MAYFAIL instead of __GFP_NORETRY when allocating at the
> beneficial order. This allows reclaim to try harder before falling back to
> smaller orders, at the cost of longer allocation setup time.
>
> That tradeoff is acceptable for beneficial-order allocations: higher-order
> backing pages can improve TLB hit rates and reduce the number of TLB
> invalidations needed when moving memory.
>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Simona Vetter <simona@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
>
> Together with other Xe/core shrinker changes currently under development,
> this change significantly improved performance under memory fragmentation
> on PTL. In 3DMark Wild Life Extreme, performance improved by up to 120%
> compared to the baseline fragmented-memory case. GravityMark also showed
> approximately a 20% improvement under similar conditions.
> ---
> drivers/gpu/drm/ttm/ttm_pool.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 9f0ab99eb289..682ae4f40424 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -168,6 +168,11 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
> if (order && beneficial_order && order != beneficial_order)
> gfp_flags &= ~__GFP_RECLAIM;
>
> + if (beneficial_order && order == beneficial_order) {
> + gfp_flags &= ~__GFP_NORETRY;
> + gfp_flags |= __GFP_RETRY_MAYFAIL;
> + }
> +
> if (!ttm_pool_uses_dma_alloc(pool)) {
> p = alloc_pages_node(pool->nid, gfp_flags, order);
> if (p) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-17 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 2:22 [PATCH] drm/ttm/pool: Try harder for beneficial orders Matthew Brost
2026-06-17 8:59 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®