[PATCH] drm/ttm/pool: Try harder for beneficial orders
From: Matthew Brost
Date: Tue Jun 16 2026 - 22:25:25 EST
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@xxxxxxx>
Cc: Huang Rui <ray.huang@xxxxxxx>
Cc: Matthew Auld <matthew.auld@xxxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Cc: Maxime Ripard <mripard@xxxxxxxxxx>
Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: David Airlie <airlied@xxxxxxxxx>
Cc: Simona Vetter <simona@xxxxxxxx>
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx>
Signed-off-by: Matthew Brost <matthew.brost@xxxxxxxxx>
---
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