Skip to contentSkip to conversation

drm/amdgpu: always allocate cleared VRAM for GEM allocations

PATCH In review Alex Deucher 4 participants 6 messages Aug 29, 2024 – Sep 10, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 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.

In addition this fixes the high CPU spikes seen when doing wipe on release.

v2: always set AMDGPU_GEM_CREATE_VRAM_CLEARED (Christian)

Fixes a68c7eaa7a8f ("drm/amdgpu: Enable clear page functionality")
Cc Arunpravin Paneer Selvam <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -0
index 1f149c9e2177..8794661b0bfa 100644
@@ -349,6 +349,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 
+	/* always clear 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.46.0
Acked-by Arunpravin Paneer Selvam on v1 1/1
#1 lore raw

this will fix performance issues,

Acked-by Arunpravin Paneer Selvam <[email protected] <mailto:[email protected]>>
Quoted 33 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.

In addition this fixes the high CPU spikes seen when doing wipe on release.

v2: always set AMDGPU_GEM_CREATE_VRAM_CLEARED (Christian)

Fixes a68c7eaa7a8f ("drm/amdgpu: Enable clear page functionality")
Cc Arunpravin Paneer Selvam<[email protected]>
Cc Christian König<[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -0
index 1f149c9e2177..8794661b0bfa 100644
@@ -349,6 +349,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
  		return -EINVAL;
  	}
 
+	/* always clear 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)) {
#2 lore raw

Can you also bump the DRM version, so that userspace knows when to skip its own clear?

Also, clearing with SDMA takes up to 33 times more time (= is up to 97% slower) than clearing with compute.

Marek

Quoted 41 lines · Arunpravin

this will fix performance issues,

On 8/29/2024 10:56 PM, Alex Deucher wrote:

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.

In addition this fixes the high CPU spikes seen when doing wipe on release.

v2: always set AMDGPU_GEM_CREATE_VRAM_CLEARED (Christian)

Fixes a68c7eaa7a8f ("drm/amdgpu: Enable clear page functionality")
Cc Arunpravin Paneer Selvam <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -0
index 1f149c9e2177..8794661b0bfa 100644
@@ -349,6 +349,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
  return -EINVAL;
  }
 
+ /* always clear 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)) {
#3 lore raw
Quoted 3 lines · Marek Olšák

Can you also bump the DRM version, so that userspace knows when to skip its own clear?

Sure, although going forward, it might be better to migrate to a generic flags query in the INFO ioctl so we can just check for various feature bits so we can backport functionality to older kernels more easily.

Alex

Quoted 49 lines

Also, clearing with SDMA takes up to 33 times more time (= is up to 97% slower) than clearing with compute.

Marek

Quoted 41 lines · Arunpravin

this will fix performance issues,

On 8/29/2024 10:56 PM, Alex Deucher wrote:

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.

In addition this fixes the high CPU spikes seen when doing wipe on release.

v2: always set AMDGPU_GEM_CREATE_VRAM_CLEARED (Christian)

Fixes a68c7eaa7a8f ("drm/amdgpu: Enable clear page functionality")
Cc Arunpravin Paneer Selvam <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -0
index 1f149c9e2177..8794661b0bfa 100644
@@ -349,6 +349,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
  return -EINVAL;
  }
 
+ /* always clear 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)) {
#4 lore raw
Quoted 10 lines · Alex Deucher
Quoted 3 lines · Marek Olšák

Can you also bump the DRM version, so that userspace knows when to skip its own clear?

Sure, although going forward, it might be better to migrate to a generic flags query in the INFO ioctl so we can just check for various feature bits so we can backport functionality to older kernels more easily.

How it's exposed is up to you.

Marek

#5 lore raw
In reply to Marek Olšák

Thanks, I will try clearing with compute and check the performance.

Regards,
Arun.

Quoted 50 lines · Marek Olšák

Can you also bump the DRM version, so that userspace knows when to skip its own clear?

Also, clearing with SDMA takes up to 33 times more time (= is up to 97% slower) than clearing with compute.

Marek

Quoted 40 lines · Arunpravin

this will fix performance issues,

On 8/29/2024 10:56 PM, Alex Deucher wrote:

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.

In addition this fixes the high CPU spikes seen when doing wipe on release.

v2: always set AMDGPU_GEM_CREATE_VRAM_CLEARED (Christian)

Fixes a68c7eaa7a8f ("drm/amdgpu: Enable clear page functionality")
Cc Arunpravin Paneer Selvam <[email protected]>
Cc Christian König <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -0
index 1f149c9e2177..8794661b0bfa 100644
@@ -349,6 +349,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
   return -EINVAL;
   }
 
+ /* always clear 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)) {