Skip to contentSkip to conversation

drm/amdgpu: always allocate cleared VRAM for KFD allocations

PATCH In review Alex Deucher 3 participants 4 messages Mar 26, 2024 – Apr 3, 2024

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 drm/amdgpu: always allocate cleared VRAM for KFD allocations

This adds allocation latency, but aligns better with user expectations. The latency should improve with the drm buddy clearing patches that Arun has been working on.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -1
index 0ae9fd844623..f9a4ea082821 100644
@@ -1709,7 +1709,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 			alloc_domain = AMDGPU_GEM_DOMAIN_GTT;
 			alloc_flags = 0;
 		} else {
-			alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+			alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE |
+				AMDGPU_GEM_CREATE_VRAM_CLEARED;
 			alloc_flags |= (flags & KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC) ?
 			AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED : 0;
 		}
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 2/2 drm/amdgpu: always allocate cleared VRAM for GEM allocations

This adds allocation latency, but aligns better with user expectations. The latency should improve with the drm buddy clearing patches that Arun has been working on.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
index 6bbab141eaae..cecaacc1affe 100644
@@ -346,6 +346,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 
+	/* always clear VRAM */
+	if (args->in.domains & AMDGPU_GEM_DOMAIN_VRAM)
+		flags |= AMDGPU_GEM_CREATE_VRAM_CLEARED;
+
 	/* create a gem object to contain this object in */
 	if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |
 	    AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
Signature · 1 line
2.44.0
maintainer
#2 lore raw
In reply to Alex Deucher
Quoted 3 lines · Alex Deucher

This adds allocation latency, but aligns better with user expectations. The latency should improve with the drm buddy clearing patches that Arun has been working on.

If we submit this before the clear-page-tracking patches are in, this will cause unacceptable performance regressions for ROCm applications.

Regards,
  Felix

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -1
index 0ae9fd844623..f9a4ea082821 100644
@@ -1709,7 +1709,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
  			alloc_domain = AMDGPU_GEM_DOMAIN_GTT;
  			alloc_flags = 0;
  		} else {
-			alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+			alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE |
+				AMDGPU_GEM_CREATE_VRAM_CLEARED;
  			alloc_flags |= (flags & KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC) ?
  			AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED : 0;
  		}
#3 lore raw
Quoted 7 lines · Felix Kuehling
Quoted 3 lines · Alex Deucher

This adds allocation latency, but aligns better with user expectations.  The latency should improve with the drm buddy clearing patches that Arun has been working on.

If we submit this before the clear-page-tracking patches are in, this will cause unacceptable performance regressions for ROCm applications.

I agree this probably shouldn't land earlier than that, ideally together or shortly after though.

Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer