[RFC PATCH 03/18] drm/ttm: Implement BO eviction tracking

2024-04-24 Thread Friedrich Vock
For each buffer object, remember evictions and try undoing them if memory pressure gets lower again. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 28 +++- drivers/gpu/drm/ttm/ttm_bo_util.c | 3 +++ 2 files changed, 30 insertions(+), 1 deletion

[RFC PATCH 14/18] drm/ttm: Consider BOs placed in non-favorite locations evicted

2024-04-24 Thread Friedrich Vock
If we didn't get the favorite placement because it was full, we should try moving it into the favorite placement once there is space. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 28 +++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git

[RFC PATCH 18/18] drm/amdgpu: Bump minor version

2024-04-24 Thread Friedrich Vock
Indicates support for EVICTED_VRAM queries and AMDGPU_GEM_OP_SET_PRIORITY Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu

[RFC PATCH 01/18] drm/ttm: Add tracking for evicted memory

2024-04-24 Thread Friedrich Vock
These utilities will be used to keep track of what buffers have been evicted from any particular place, to try and decide when to try undoing the eviction. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_device.c | 1 + drivers/gpu/drm/ttm/ttm_resource.c | 14

[RFC PATCH 00/18] TTM interface for managing VRAM oversubscription

2024-04-24 Thread Friedrich Vock
? Thanks, Friedrich [1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6833 [2] https://gitlab.freedesktop.org/pixelcluster/mesa/-/tree/spilling Friedrich Vock (18): drm/ttm: Add tracking for evicted memory drm/ttm: Add per-BO eviction tracking drm/ttm: Implement BO eviction tra

[RFC PATCH 15/18] drm/amdgpu: Set a default priority for user/kernel BOs

2024-04-24 Thread Friedrich Vock
Reserve the highest priority for the kernel, and choose a balanced value as userspace default. Userspace is intended to be able to modify these later to mark buffers as important/unimportant. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c| 1 + drivers/gpu/drm/amd

[RFC PATCH 07/18] drm/amdgpu: Add TTM uneviction control functions

2024-04-24 Thread Friedrich Vock
Try unevicting only VRAM/GTT BOs. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 50 + 1 file changed, 50 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 64f5001a7dc5d

[RFC PATCH 04/18] drm/ttm: Add driver funcs for uneviction control

2024-04-24 Thread Friedrich Vock
Provides fine-grained control for drivers over which buffers should be considered when attempting to undo evictions. Signed-off-by: Friedrich Vock --- include/drm/ttm/ttm_device.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/include/drm/ttm/ttm_device.h b/include

[RFC PATCH 08/18] drm/amdgpu: Don't try moving BOs to preferred domain before submit

2024-04-24 Thread Friedrich Vock
TTM now takes care of moving buffers to the best possible domain. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 2 - drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 191 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.h | 4 - drivers/gpu/drm/amd

[RFC PATCH 09/18] drm/amdgpu: Don't mark VRAM as a busy placement for VRAM|GTT resources

2024-04-24 Thread Friedrich Vock
We will never try evicting things from VRAM for these resources anyway. This affects TTM buffer uneviction logic, which would otherwise try to move these buffers into VRAM (clashing with VRAM-only allocations). Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13

[RFC PATCH 02/18] drm/ttm: Add per-BO eviction tracking

2024-04-24 Thread Friedrich Vock
Make each buffer object aware of whether it has been evicted or not. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 1 + include/drm/ttm/ttm_bo.h | 11 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c

[RFC PATCH 05/18] drm/ttm: Add option to evict no BOs in operation

2024-04-24 Thread Friedrich Vock
When undoing evictions because of decreased memory pressure, it makes no sense to try evicting other buffers. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 2 ++ include/drm/ttm/ttm_bo.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b

[RFC PATCH 06/18] drm/ttm: Add public buffer eviction/uneviction functions

2024-04-24 Thread Friedrich Vock
For now, they are only used internally inside TTM, but this will change with the introduction of dynamic buffer priorities. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 168 ++- include/drm/ttm/ttm_bo.h | 6 ++ 2 files changed, 172

[RFC PATCH 12/18] drm/ttm: Do not evict BOs with higher priority

2024-04-24 Thread Friedrich Vock
This makes buffer eviction significantly more stable by avoiding ping-ponging caused by low-priority buffers evicting high-priority buffers and vice versa. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 9 +++-- drivers/gpu/drm/ttm/ttm_resource.c | 5 +++-- include

[RFC PATCH 13/18] drm/ttm: Implement ttm_bo_update_priority

2024-04-24 Thread Friedrich Vock
Used to dynamically adjust priorities of buffers at runtime, to react to changes in memory pressure/usage patterns. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/ttm/ttm_bo.c | 17 + include/drm/ttm/ttm_bo.h | 2 ++ 2 files changed, 19 insertions(+) diff --git

[RFC PATCH 10/18] drm/amdgpu: Don't add GTT to initial domains after failing to allocate VRAM

2024-04-24 Thread Friedrich Vock
This adds GTT to the "preferred domains" of this buffer object, which will also prevent any attempts at moving the buffer back to VRAM if there is space. If VRAM is full, GTT will already be chosen as a fallback. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_ge

[RFC PATCH 11/18] drm/ttm: Bump BO priority count

2024-04-24 Thread Friedrich Vock
For adjustable priorities by userspace, it is nice to have a bit more granularity. Signed-off-by: Friedrich Vock --- include/drm/ttm/ttm_resource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h index

[RFC PATCH 16/18] drm/amdgpu: Implement SET_PRIORITY GEM op

2024-04-24 Thread Friedrich Vock
Used by userspace to adjust buffer priorities in response to changes in application demand and memory pressure. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 20 include/uapi/drm/amdgpu_drm.h | 1 + 2 files changed, 21 insertions

[RFC PATCH 17/18] drm/amdgpu: Implement EVICTED_VRAM query

2024-04-24 Thread Friedrich Vock
Used by userspace to gauge the severity of memory overcommit and make prioritization decisions based on it. Used by userspace to gauge the severity of memory overcommit and make prioritization decisions based on it. Signed-off-by: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3

Re: [RFC PATCH 16/18] drm/amdgpu: Implement SET_PRIORITY GEM op

2024-04-25 Thread Friedrich Vock
On 25.04.24 08:32, Christian König wrote: Am 24.04.24 um 18:57 schrieb Friedrich Vock: Used by userspace to adjust buffer priorities in response to changes in application demand and memory pressure. Yeah, that was discussed over and over again. One big design criteria is that we can't have

Re: [RFC PATCH 16/18] drm/amdgpu: Implement SET_PRIORITY GEM op

2024-04-25 Thread Friedrich Vock
On 25.04.24 08:58, Christian König wrote: Am 25.04.24 um 08:46 schrieb Friedrich Vock: On 25.04.24 08:32, Christian König wrote: Am 24.04.24 um 18:57 schrieb Friedrich Vock: Used by userspace to adjust buffer priorities in response to changes in application demand and memory pressure. Yeah

Re: [RFC PATCH 10/18] drm/amdgpu: Don't add GTT to initial domains after failing to allocate VRAM

2024-04-25 Thread Friedrich Vock
On 25.04.24 08:25, Christian König wrote: Am 24.04.24 um 18:57 schrieb Friedrich Vock: This adds GTT to the "preferred domains" of this buffer object, which will also prevent any attempts at moving the buffer back to VRAM if there is space. If VRAM is full, GTT will already

Re: [RFC PATCH 16/18] drm/amdgpu: Implement SET_PRIORITY GEM op

2024-04-25 Thread Friedrich Vock
On 25.04.24 09:15, Christian König wrote: Am 25.04.24 um 09:06 schrieb Friedrich Vock: On 25.04.24 08:58, Christian König wrote: Am 25.04.24 um 08:46 schrieb Friedrich Vock: On 25.04.24 08:32, Christian König wrote: Am 24.04.24 um 18:57 schrieb Friedrich Vock: Used by userspace to adjust

Re: [RFC 1/5] drm/amdgpu: Fix migration rate limiting accounting

2024-05-08 Thread Friedrich Vock
-by: Tvrtko Ursulin Cc: Christian König Cc: Friedrich Vock --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index ec888fc6ead8

Re: [RFC PATCH 00/18] TTM interface for managing VRAM oversubscription

2024-05-13 Thread Friedrich Vock
Hi, On 02.05.24 16:23, Maarten Lankhorst wrote: Hey, [snip] For Xe, I've been loking at using cgroups. A small prototype is available at https://cgit.freedesktop.org/~mlankhorst/linux/log/?h=dumpcg To stimulate discussion, I've added amdgpu support as well. This should make it possible to

Re: [RFC 1/5] drm/amdgpu: Fix migration rate limiting accounting

2024-05-13 Thread Friedrich Vock
On 09.05.24 11:19, Tvrtko Ursulin wrote: On 08/05/2024 20:08, Friedrich Vock wrote: On 08.05.24 20:09, Tvrtko Ursulin wrote: From: Tvrtko Ursulin The logic assumed any migration attempt worked and therefore would over- account the amount of data migrated during buffer re-validation