Skip to contentSkip to conversation

drm/amdgpu: Avoid extra evict-restore process.

PATCH In review Gang Ba 2 participants 2 messages Jul 8, 2025 – Jul 9, 2025

Subsystems (2)
lore
Share & tools
lore

Gang Ba

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Avoid extra evict-restore process.

If vm belongs to another process, this is fclose after fork,
wait may enable signaling KFD eviction fence and cause parent process queue evicted.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
index f042372d9f2e..8ee1b7e62dee 100644
@@ -2410,6 +2410,13 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
  */
 long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
 {
+	/* If vm belongs to another process, this is fclose after fork,
+	 * wait may enable signaling KFD eviction fence and cause parent process queue evicted.
+	 */
+	if (vm->task_info->tgid &&
+	    vm->task_info->tgid != current->group_leader->pid)
+	      return 0;
+
 	timeout = dma_resv_wait_timeout(vm->root.bo->tbo.base.resv,
 					DMA_RESV_USAGE_BOOKKEEP,
 					true, timeout);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 13 lines · Gang Ba

If vm belongs to another process, this is fclose after fork,
wait may enable signaling KFD eviction fence and cause parent process queue evicted.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index f042372d9f2e..8ee1b7e62dee 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size, · line 2419

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
@@ -2410,6 +2410,13 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
   */
  long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
  {
+	/* If vm belongs to another process, this is fclose after fork,
+	 * wait may enable signaling KFD eviction fence and cause parent process queue evicted.
+	 */
+	if (vm->task_info->tgid &&
+	    vm->task_info->tgid != current->group_leader->pid)
+	      return 0;
+

Only check this for KFD vm, in case this may cause gfx test regression.

    if (vm->is_compute_context && vm->task_info->tgid != current->group_leader->pid)

          return 0;

Regards,

Philip

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  	timeout = dma_resv_wait_timeout(vm->root.bo->tbo.base.resv,
  					DMA_RESV_USAGE_BOOKKEEP,
  					true, timeout);