Skip to contentSkip to conversation

drm/amdgpu: Let BO created in its allowed_domain

PATCH NAK xinhui pan 2 participants 4 messages Sep 17, 2021

Subsystems (2)
lore
Share & tools
lore

xinhui pan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Let BO created in its allowed_domain

For any user BO, it is allowed to alloc memory in both GTT and VRAM domain. That means one VRAM BO could be eviced to GTT.

Now if device is already lack of VRAM, this BO could alloc memory from GTT directly without evicting other VRAM BO. In this way we can reduce memory evictions.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 66bb8a53bb20..9a547bb38cda 100644
@@ -579,7 +579,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
 			  AMDGPU_GEM_DOMAIN_GDS))
 		amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
 	else
-		amdgpu_bo_placement_from_domain(bo, bp->domain);
+		amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
 	if (bp->type == ttm_bo_type_kernel)
 		bo->tbo.priority = 1;
 
Signature · 1 line
2.25.1
maintainer NAK
#1 lore raw

Am 17.09.21 um 09:04 schrieb xinhui pan:

Quoted 6 lines

For any user BO, it is allowed to alloc memory in both GTT and VRAM domain. That means one VRAM BO could be eviced to GTT.

Now if device is already lack of VRAM, this BO could alloc memory from GTT directly without evicting other VRAM BO. In this way we can reduce memory evictions.

NAK, that is intentional pressure on VRAM during allocation of new memory.

Christian.

Quoted 19 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 66bb8a53bb20..9a547bb38cda 100644
@@ -579,7 +579,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  			  AMDGPU_GEM_DOMAIN_GDS))
  		amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
  	else
-		amdgpu_bo_placement_from_domain(bo, bp->domain);
+		amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
  	if (bp->type == ttm_bo_type_kernel)
  		bo->tbo.priority = 1;
 
author NAK
#2 lore raw

[AMD Official Use Only]

Why? just to evict some inactive vram BOs?
________________________________
From: Koenig, Christian <[email protected]>
Sent: Friday, September 17, 2021 3:06:16 PM
To: Pan, Xinhui <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Let BO created in its allowed_domain

Am 17.09.21 um 09:04 schrieb xinhui pan:

Quoted 6 lines

For any user BO, it is allowed to alloc memory in both GTT and VRAM domain. That means one VRAM BO could be eviced to GTT.

Now if device is already lack of VRAM, this BO could alloc memory from GTT directly without evicting other VRAM BO. In this way we can reduce memory evictions.

NAK, that is intentional pressure on VRAM during allocation of new memory.

Christian.

Quoted 19 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 66bb8a53bb20..9a547bb38cda 100644
@@ -579,7 +579,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
                         AMDGPU_GEM_DOMAIN_GDS))
               amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
       else
-             amdgpu_bo_placement_from_domain(bo, bp->domain);
+             amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
       if (bp->type == ttm_bo_type_kernel)
               bo->tbo.priority = 1;
 
maintainer
#3 lore raw

Exactly that, yes. The idea is that we want to create at least some pressure on VRAM when VRAM|GTT is specified.

Essentially we would like to have that for CS as well, but it's just hard to find the right balance between no pressure and the full pressure of VRAM placement for VRAM|GTT BOs.

It's on my todo list to tackle that and I'm currently working on an userspace tool to better simulate those setups, but it's just a side project.

Christian.

Am 17.09.21 um 09:35 schrieb Pan, Xinhui:

Quoted 45 lines

[AMD Official Use Only]

Why? just to evict some inactive vram BOs?
------------------------------------------------------------------------
*From:* Koenig, Christian <[email protected]>
*Sent:* Friday, September 17, 2021 3:06:16 PM
*To:* Pan, Xinhui <[email protected]>; [email protected] <[email protected]> *Cc:* Deucher, Alexander <[email protected]>
*Subject:* Re: [PATCH] drm/amdgpu: Let BO created in its allowed_domain
Am 17.09.21 um 09:04 schrieb xinhui pan:

Quoted 6 lines

For any user BO, it is allowed to alloc memory in both GTT and VRAM domain. That means one VRAM BO could be eviced to GTT.

Now if device is already lack of VRAM, this BO could alloc memory from GTT directly without evicting other VRAM BO. In this way we can reduce memory evictions.

NAK, that is intentional pressure on VRAM during allocation of new memory.

Christian.

Review

Quoted 7 lines

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-

   1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 580

Quoted 6 lines

index 66bb8a53bb20..9a547bb38cda 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
@@ -579,7 +579,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
                           AMDGPU_GEM_DOMAIN_GDS))
                 amdgpu_bo_placement_from_domain(bo, 

AMDGPU_GEM_DOMAIN_CPU);

Quoted 6 lines

        else
-             amdgpu_bo_placement_from_domain(bo, bp->domain); +             amdgpu_bo_placement_from_domain(bo, bo->allowed_domains); if (bp->type == ttm_bo_type_kernel)
                bo->tbo.priority = 1;