Skip to contentSkip to conversation

drm/amdgpu: Checkpoint and Restore VRAM BOs without VA

PATCH In review Ramesh Errabolu 2 participants 2 messages Jul 25, 2023

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

PATCH v2 1/1 drm/amdgpu: Checkpoint and Restore VRAM BOs without VA

Extend checkpoint logic to allow inclusion of VRAM BOs that do not have a VA attached

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +7 -2
index 40ac093b5035..44c647c82070 100644
@@ -1845,7 +1845,8 @@ static uint32_t get_process_num_bos(struct kfd_process *p)
 		idr_for_each_entry(&pdd->alloc_idr, mem, id) {
 			struct kgd_mem *kgd_mem = (struct kgd_mem *)mem;
 
-			if ((uint64_t)kgd_mem->va > pdd->gpuvm_base)
+			if (((uint64_t)kgd_mem->va > pdd->gpuvm_base) ||
+			    !kgd_mem->va)
 				num_of_bos++;
 		}
 	}
@@ -1917,7 +1918,11 @@ static int criu_checkpoint_bos(struct kfd_process *p,
 			kgd_mem = (struct kgd_mem *)mem;
 			dumper_bo = kgd_mem->bo;
 
-			if ((uint64_t)kgd_mem->va <= pdd->gpuvm_base)
+			/* Skip checkpointing BOs that are used for Trap handler
+			 * code and state. Currently, these BOs have a VA that
+			 * is less GPUVM Base
+			 */
+			if (((uint64_t)kgd_mem->va <= pdd->gpuvm_base) && kgd_mem->va)
 				continue;
 
 			bo_bucket = &bo_buckets[bo_index];
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 2023-07-25 um 17:11 schrieb Ramesh Errabolu:

Quoted 13 lines

Extend checkpoint logic to allow inclusion of VRAM BOs that do not have a VA attached

---
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index 40ac093b5035..44c647c82070 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static uint32_t get_process_num_bos(struct kfd_process *p) · line 1848

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
@@ -1845,7 +1845,8 @@ static uint32_t get_process_num_bos(struct kfd_process *p)
  		idr_for_each_entry(&pdd->alloc_idr, mem, id) {
  			struct kgd_mem *kgd_mem = (struct kgd_mem *)mem;
 
-			if ((uint64_t)kgd_mem->va > pdd->gpuvm_base)
+			if (((uint64_t)kgd_mem->va > pdd->gpuvm_base) ||

Unnecessary parentheses around (a > b).

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -0
+			    !kgd_mem->va)
  				num_of_bos++;
  		}
  	}

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int criu_checkpoint_bos(struct kfd_process *p, · line 1925

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +5 -1
@@ -1917,7 +1918,11 @@ static int criu_checkpoint_bos(struct kfd_process *p,
  			kgd_mem = (struct kgd_mem *)mem;
  			dumper_bo = kgd_mem->bo;
 
-			if ((uint64_t)kgd_mem->va <= pdd->gpuvm_base)
+			/* Skip checkpointing BOs that are used for Trap handler
+			 * code and state. Currently, these BOs have a VA that
+			 * is less GPUVM Base
+			 */
+			if (((uint64_t)kgd_mem->va <= pdd->gpuvm_base) && kgd_mem->va)

Unnecessary parentheses around (a <= b). In this condition I'd also prefer to put kgd_mem->va first, because it short-circuits execution for the case that va is NULL.

With that fixed, the patch is

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
  				continue;
 
  			bo_bucket = &bo_buckets[bo_index];