Triggering kswap at an order higher than beneficial_order makes little
sense, as the driver has already indicated the optimal order at which
reclaim is effective. Similarly, issuing direct reclaim or triggering
kswap at a lower order than beneficial_order is ineffective, since the
driver does not benefit from reclaiming lower-order pages.

As a result, direct reclaim should only be issued with __GFP_NORETRY at
exactly beneficial_order, or as a fallback, direct reclaim without
__GFP_NORETRY at order 0 when failure is not an option.

Signed-off-by: Matthew Brost <[email protected]>
Reviewed-by: Christian Koenig <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>

---

This was part of a larger shrinker series in Xe and is unlikely to be
merged soon, as it is stuck in review. Send this reviewed, low-hanging
TTM patch on its own, as it slightly helps address Xe's shrinker issues.
---
 drivers/gpu/drm/ttm/ttm_pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 278bbe7a11ad..e76c3a5c67bd 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -165,8 +165,8 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool 
*pool, gfp_t gfp_flags,
         * Do not add latency to the allocation path for allocations orders
         * device tolds us do not bring them additional performance gains.
         */
-       if (beneficial_order && order > beneficial_order)
-               gfp_flags &= ~__GFP_DIRECT_RECLAIM;
+       if (order && beneficial_order && order != beneficial_order)
+               gfp_flags &= ~__GFP_RECLAIM;
 
        if (!ttm_pool_uses_dma_alloc(pool)) {
                p = alloc_pages_node(pool->nid, gfp_flags, order);
-- 
2.34.1

Reply via email to