Skip to contentSkip to conversation

drm/amdkfd: wait migration done only if migration starts

PATCH In review Philip Yang 3 participants 5 messages Apr 29, 2021 – May 5, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdkfd: wait migration done only if migration starts

If migration vma setup, but failed before start sdma memory copy, e.g. process is killed, don't wait for sdma fence done.

---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +12 -8
index 6b810863f6ba..19b08247ba8a 100644
@@ -460,10 +460,12 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
 	}
 
 	if (migrate.cpages) {
-		svm_migrate_copy_to_vram(adev, prange, &migrate, &mfence,
-					 scratch);
-		migrate_vma_pages(&migrate);
-		svm_migrate_copy_done(adev, mfence);
+		r = svm_migrate_copy_to_vram(adev, prange, &migrate, &mfence,
+					     scratch);
+		if (!r) {
+			migrate_vma_pages(&migrate);
+			svm_migrate_copy_done(adev, mfence);
+		}
 		migrate_vma_finalize(&migrate);
 	}
 
@@ -663,10 +665,12 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
 	pr_debug("cpages %ld\n", migrate.cpages);
 
 	if (migrate.cpages) {
-		svm_migrate_copy_to_ram(adev, prange, &migrate, &mfence,
-					scratch);
-		migrate_vma_pages(&migrate);
-		svm_migrate_copy_done(adev, mfence);
+		r = svm_migrate_copy_to_ram(adev, prange, &migrate, &mfence,
+					    scratch);
+		if (!r) {
+			migrate_vma_pages(&migrate);
+			svm_migrate_copy_done(adev, mfence);
+		}
 		migrate_vma_finalize(&migrate);
 	} else {
 		pr_debug("failed collect migrate device pages [0x%lx 0x%lx]\n",
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 2/2 drm/amdkfd: flush TLB after updating GPU page table

To workaround the situation that vm retry fault keep coming after page table update. We are investigating the root cause, but once this issue happens, application will stuck and sometimes have to reboot to recover.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -0
index d9111fea724b..a165e51c4a1c 100644
@@ -1225,6 +1225,9 @@ static int svm_range_map_to_gpus(struct svm_range *prange,
 				break;
 			}
 		}
+
+		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
+						  p->pasid);
 	}
 
 	return r;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdkfd: flush TLB after updating GPU page table

Am 2021-04-28 um 9:53 p.m. schrieb Philip Yang:

Quoted 5 lines

To workaround the situation that vm retry fault keep coming after page table update. We are investigating the root cause, but once this issue happens, application will stuck and sometimes have to reboot to recover.

This patch is

Quoted 9 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
index d9111fea724b..a165e51c4a1c 100644

drivers/gpu/drm/amd/amdkfd/kfd_svm.c static int svm_range_map_to_gpus(struct svm_range *prange, · line 1233

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -0
@@ -1225,6 +1225,9 @@ static int svm_range_map_to_gpus(struct svm_range *prange,
 				break;
 			}
 		}
+
+		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
+						  p->pasid);
 	}
 
 	return r;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#3 lore raw
In reply to Philip Yang

Am 2021-04-28 um 9:53 p.m. schrieb Philip Yang:

Quoted 2 lines

If migration vma setup, but failed before start sdma memory copy, e.g. process is killed, don't wait for sdma fence done.

I think you could describe this more generally as "Handle errors returned by svm_migrate_copy_to_vram/ram".

Quoted 13 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index 6b810863f6ba..19b08247ba8a 100644
@@ -460,10 +460,12 @@ svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
 	}
 

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_vma_to_vram(struct amdgpu_device *adev, struct svm_range *prange, · line 467

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +5 -4
 	if (migrate.cpages) {
-		svm_migrate_copy_to_vram(adev, prange, &migrate, &mfence,
-					 scratch);
-		migrate_vma_pages(&migrate);
-		svm_migrate_copy_done(adev, mfence);
+		r = svm_migrate_copy_to_vram(adev, prange, &migrate, &mfence,
+					     scratch);
+		if (!r) {
+			migrate_vma_pages(&migrate);
+			svm_migrate_copy_done(adev, mfence);

I think there are failure cases where svm_migrate_copy_to_vram successfully copies some pages but fails somewhere in the middle. I think in those cases you still want to call migrate_vma_pages and svm_migrate_copy_done. If the copy never started for some reason, there should be no mfence and svm_migrate_copy_done should be a no-op.

I probably don't understand the failure scenario you encountered. Can you explain that in more detail?

Thanks,
  Felix

Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -3
+		}
 		migrate_vma_finalize(&migrate);
 	}
 
@@ -663,10 +665,12 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange,
 	pr_debug("cpages %ld\n", migrate.cpages);
 
 	if (migrate.cpages) {
-		svm_migrate_copy_to_ram(adev, prange, &migrate, &mfence,
-					scratch);
-		migrate_vma_pages(&migrate);

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, · line 676

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +6 -1
-		svm_migrate_copy_done(adev, mfence);
+		r = svm_migrate_copy_to_ram(adev, prange, &migrate, &mfence,
+					    scratch);
+		if (!r) {
+			migrate_vma_pages(&migrate);
+			svm_migrate_copy_done(adev, mfence);
+		}
 		migrate_vma_finalize(&migrate);
 	} else {
 		pr_debug("failed collect migrate device pages [0x%lx 0x%lx]\n",

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx