[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250918-ttm_pool_no_direct_reclaim-v2-3-135294e1f8a2@igalia.com>
Date: Thu, 18 Sep 2025 17:09:26 -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 3/3] drm/amdgpu: allow allocation preferences when
creating GEM object
When creating a GEM object on amdgpu, it may be specified that latency
during allocation should be preferred over throughput when processing.
That will reflect into the TTM operation, which will lead to the use of
direct reclaim for higher order pages when throughput is preferred, even if
latency is configured to be preferred in the system.
If latency is preferred, no direct reclaim will be used for higher order
pages, which might lead to more use of lower order pages, which can also
compromised throughput.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@...lia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
include/uapi/drm/amdgpu_drm.h | 9 +++++++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index d1ccbfcf21fa62a8d4fe1b8f020cf00d34efe1ab..0a0333e7ed1a45de63fedfbc161094f6de7fda00 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -451,7 +451,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
AMDGPU_GEM_CREATE_ENCRYPTED |
AMDGPU_GEM_CREATE_GFX12_DCC |
- AMDGPU_GEM_CREATE_DISCARDABLE))
+ AMDGPU_GEM_CREATE_DISCARDABLE |
+ AMDGPU_GEM_ALLOCATION_MASK))
return -EINVAL;
/* reject invalid gem domains */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 122a882948839464dc197d40ff8e46cf161f7b42..54350460bb41e4bc057eb61d7bb6014457e56c6e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -632,7 +632,8 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
/* We opt to avoid OOM on system pages allocations */
.gfp_retry_mayfail = true,
.allow_res_evict = bp->type != ttm_bo_type_kernel,
- .resv = bp->resv
+ .resv = bp->resv,
+ .alloc_method = AMDGPU_GEM_ALLOCATION(bp->flags)
};
struct amdgpu_bo *bo;
unsigned long page_align, size = bp->size;
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index bdedbaccf776db0c86cec939725a435c37f09f77..b796744abeba2bf4b14556251b36938ba0905c1e 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -180,6 +180,15 @@ extern "C" {
/* Set PTE.D and recompress during GTT->VRAM moves according to TILING flags. */
#define AMDGPU_GEM_CREATE_GFX12_DCC (1 << 16)
+/* Prioritize allocation latency or high-order allocations that favor
+ * throughput */
+#define AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT (17)
+#define AMDGPU_GEM_ALLOCATION_DEFAULT (0 << AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT)
+#define AMDGPU_GEM_ALLOCATION_LATENCY (2 << AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT)
+#define AMDGPU_GEM_ALLOCATION_THROUGHPUT (3 << AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT)
+#define AMDGPU_GEM_ALLOCATION_MASK (3 << AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT)
+#define AMDGPU_GEM_ALLOCATION(flags) ((flags & AMDGPU_GEM_ALLOCATION_MASK) >> AMDGPU_GEM_OVERRIDE_ALLOCATION_SHIFT)
+
struct drm_amdgpu_gem_create_in {
/** the requested memory size */
__u64 bo_size;
--
2.47.3
Powered by blists - more mailing lists