[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250918-ttm_pool_no_direct_reclaim-v2-2-135294e1f8a2@igalia.com>
Date: Thu, 18 Sep 2025 17:09:25 -0300
From: Thadeu Lima de Souza Cascardo <cascardo@...lia.com>
To: Christian Koenig <christian.koenig@....com>,
Michel Dänzer <michel.daenzer@...lbox.org>,
Huang Rui <ray.huang@....com>, Matthew Auld <matthew.auld@...el.com>,
Matthew Brost <matthew.brost@...el.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kernel-dev@...lia.com,
Tvrtko Ursulin <tvrtko.ursulin@...lia.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Thadeu Lima de Souza Cascardo <cascardo@...lia.com>
Subject: [PATCH RFC v2 2/3] ttm: pool: add a module parameter to set
latency preference
This allows a system-wide setting for allocations of higher order pages not
to use direct reclaim. The default setting is to keep existing behavior and
allow direct reclaim when allocating higher order pages.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@...lia.com>
---
drivers/gpu/drm/ttm/ttm_pool.c | 12 ++++++++++--
drivers/gpu/drm/ttm/ttm_tt.c | 2 +-
include/drm/ttm/ttm_pool.h | 2 +-
include/drm/ttm/ttm_tt.h | 2 +-
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 02c622a103fcece003bd70ce6b5833ada70f5228..39203f2c247a36b0389682d7fb841088f4c8a95b 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -56,6 +56,11 @@ static DECLARE_FAULT_ATTR(backup_fault_inject);
#define should_fail(...) false
#endif
+static unsigned int ttm_alloc_method;
+
+MODULE_PARM_DESC(alloc_method, "TTM allocation method (0 - throughput, 1 - latency");
+module_param_named(alloc_method, ttm_alloc_method, uint, 0644);
+
/**
* struct ttm_pool_dma - Helper object for coherent DMA mappings
*
@@ -702,7 +707,7 @@ static unsigned int ttm_pool_alloc_find_order(unsigned int highest,
}
static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
- const struct ttm_operation_ctx *ctx,
+ struct ttm_operation_ctx *ctx,
struct ttm_pool_alloc_state *alloc,
struct ttm_pool_tt_restore *restore)
{
@@ -717,6 +722,9 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
WARN_ON(!alloc->remaining_pages || ttm_tt_is_populated(tt));
WARN_ON(alloc->dma_addr && !pool->dev);
+ if (ctx->alloc_method == ttm_op_alloc_default && ttm_alloc_method == 1)
+ ctx->alloc_method = ttm_op_alloc_latency;
+
if (tt->page_flags & TTM_TT_FLAG_ZERO_ALLOC)
gfp_flags |= __GFP_ZERO;
@@ -837,7 +845,7 @@ EXPORT_SYMBOL(ttm_pool_alloc);
* Returns: 0 on successe, negative error code otherwise.
*/
int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
- const struct ttm_operation_ctx *ctx)
+ struct ttm_operation_ctx *ctx)
{
struct ttm_pool_alloc_state alloc;
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 506e257dfba8501815f8416e808f437e5f17aa8f..e1975d740b948f9b7fe1d35d913a458026d2c783 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -294,7 +294,7 @@ long ttm_tt_backup(struct ttm_device *bdev, struct ttm_tt *tt,
}
int ttm_tt_restore(struct ttm_device *bdev, struct ttm_tt *tt,
- const struct ttm_operation_ctx *ctx)
+ struct ttm_operation_ctx *ctx)
{
int ret = ttm_pool_restore_and_alloc(&bdev->pool, tt, ctx);
diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h
index 54cd34a6e4c0ac5e17844b50fd08e72143b460c1..08f9a1388754fac352058ac2beb2b59bb944477c 100644
--- a/include/drm/ttm/ttm_pool.h
+++ b/include/drm/ttm/ttm_pool.h
@@ -95,7 +95,7 @@ void ttm_pool_drop_backed_up(struct ttm_tt *tt);
long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *ttm,
const struct ttm_backup_flags *flags);
int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
- const struct ttm_operation_ctx *ctx);
+ struct ttm_operation_ctx *ctx);
int ttm_pool_mgr_init(unsigned long num_pages);
void ttm_pool_mgr_fini(void);
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
index 406437ad674bf1a96527b45c5a81c58a747271c1..3575e20b77f3ccbc3d9aad0afbb762055b3cb139 100644
--- a/include/drm/ttm/ttm_tt.h
+++ b/include/drm/ttm/ttm_tt.h
@@ -296,7 +296,7 @@ long ttm_tt_backup(struct ttm_device *bdev, struct ttm_tt *tt,
const struct ttm_backup_flags flags);
int ttm_tt_restore(struct ttm_device *bdev, struct ttm_tt *tt,
- const struct ttm_operation_ctx *ctx);
+ struct ttm_operation_ctx *ctx);
int ttm_tt_setup_backup(struct ttm_tt *tt);
--
2.47.3
Powered by blists - more mailing lists