drm/amdgpu: Handle duplicate BOs during process restore
Subsystems (3)
PATCH 1/1 drm/amdgpu: Handle duplicate BOs during process restore
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +10 -4
@@ -2869,14 +2869,16 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *mutex_lock (&process_info->lock); -drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("Locking VM PD failed, ret: %d\n" , ret); goto ttm_reserve_fail; + } }/* Reserve all BOs and page tables/directory. Add all BOs from
@@ -2889,8 +2891,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * gobj = &mem->bo->tbo.base; ret =drm_exec_prepare_obj (&exec, gobj,1 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, ret: %d\n" , ret); goto ttm_reserve_fail; + } } }
@@ -2950,8 +2954,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu ** validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret); goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Signature · 1 line
2.35.1
Quoted 19 lines · Mukul Joshi
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *mutex_lock (&process_info->lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2879
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-2-drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("Locking VM PD failed, ret: %d\n" , ret);
pr_err makes sense here as it indicates a persistent problem that would cause soft hangs, like in this case.
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2895
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1goto ttm_reserve_fail; + } }/* Reserve all BOs and page tables/directory. Add all BOs from @@ -2889,8 +2891,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * gobj = &mem->bo->tbo.base; ret =drm_exec_prepare_obj (&exec, gobj,1 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, ret: %d\n" , ret);
Same here, pr_err is fine.
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2958
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu ** validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret);
I'd make this a pr_debug to avoid spamming the log. validation can fail intermittently and rescheduling the worker is there to handle it.
With that fixed, the patch is
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
[AMD Official Use Only - General]
Quoted 80 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Friday, March 8, 2024 11:48 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreQuoted 9 lines · Mukul Joshi
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14++++++++++----
Quoted 13 lines
1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*mutex_lock(&process_info->lock);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2879
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-2-drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("Locking VM PD failed, ret: %d\n" , ret);
pr_errmakes sense here as it indicates a persistent problem that would cause soft hangs, like in this case.drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 6 lines
goto ttm_reserve_fail;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0+ } }/* Reserve all BOs and page tables/directory. Add all BOs from @@ -2889,8 +2891,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-1gobj = &mem->bo->tbo.base; ret =drm_exec_prepare_obj (&exec, gobj,1 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { + pr_err("drm_exec_prepare_obj failed, ret:%d\n", ret);
Same here,
pr_erris fine.drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2958
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-1* validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret);
Quoted 2 lines
I'd make this a
pr_debugto avoid spamming the log. validation can fail intermittently and rescheduling the worker is there to handle it.
Will update this to pr_debug before submitting the patch. Thank you.
Regards,
Mukul
Quoted 11 lines
With that fixed, the patch is
Reviewed-by Felix Kuehling <[email protected]>Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Quoted 36 lines · Felix Kuehling
Quoted 22 lines · Mukul Joshi
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c| 14 ++++++++++----1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*
mutex_lock(&process_info->lock);
-drm_exec_init(&exec, 0);
+drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES);Quoted 8 lines
drm_exec_until_all_locked(&exec){list_for_each_entry(peer_vm, &process_info->vm_list_head, vm_list_node){
ret =amdgpu_vm_lock_pd(peer_vm, &exec, 2);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+pr_err("Locking VM PD failed, ret: %d\n", ret);
pr_errmakes sense here as it indicates a persistent problem that would cause soft hangs, like in this case.
Quoted 17 lines
Quoted 6 lines
goto
ttm_reserve_fail;
+ }
}
/* Reserve all BOs and page tables/directory. Add all BOs fromdrivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2889,8 +2891,10 @@ intQuoted 8 lines
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*
gobj =&mem->bo->tbo.base;
ret =drm_exec_prepare_obj(&exec, gobj, 1);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+pr_err("drm_exec_prepare_obj failed, ret: %d\n", ret);Same here,
pr_erris fine.
These kind of prints - "<func name> failed <error code>" - are way too generic and if more like this are added, it will be difficult to find out even where these are coming from.
It's always better to have a context so that this translates to some useful information in dmesg - minimum context is the device or bo details or anything of that sort.
Thanks,
Lijo
Quoted 27 lines
Quoted 14 lines
goto
ttm_reserve_fail;
+ }
}
}
@@ -2950,8 +2954,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, structdma_fence__rcu*
* validations above would invalidate DMABuf imports again. */
ret =process_validate_vms(process_info, &exec.ticket); - if (ret)
+ if (ret) {
+pr_err("Validating VMs failed, ret: %d\n", ret);I'd make this a
pr_debugto avoid spamming the log. validation can fail intermittently and rescheduling the worker is there to handle it.With that fixed, the patch is
Reviewed-by Felix Kuehling <[email protected]>Quoted 4 lines
goto
validate_map_fail;
+ }
/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm,&process_info->vm_list_head,
[AMD Official Use Only - General]
Quoted 65 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 11, 2024 4:13 AM
To: Kuehling, Felix <[email protected]>; Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreQuoted 13 lines · Felix Kuehling
Quoted 12 lines · Mukul Joshi
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fenceQuoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2879
Quoted 12 lines
__rcu*mutex_lock(&process_info->lock);-
drm_exec_init(&exec, 0);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1+drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("Locking VM PD failed, ret: %d\n" , ret);Quoted 10 lines
pr_errmakes sense here as it indicates a persistent problem that would cause soft hangs, like in this case.Quoted 6 lines
goto ttm_reserve_fail; + } } /* Reserve all BOs and page tables/directory. Add all BOsfrom @@ -2889,8 +2891,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fenceQuoted 9 lines
Quoted 8 lines
__rcu*gobj = &mem->bo->tbo.base; ret = drm_exec_prepare_obj(&exec, gobj, 1); drm_exec_retry_on_contention(&exec);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1-if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, ret: %d\n" , +ret);
Quoted 6 lines
Quoted 2 lines
Same here,
pr_erris fine.These kind of prints - "<func name> failed <error code>" - are way too generic and if more like this are added, it will be difficult to find out even where these are coming from.
Will send a follow up patch to put a more meaningful message here.
Thanks,
Mukul
Quoted 36 lines
It's always better to have a context so that this translates to some useful information in dmesg - minimum context is the device or bo details or anything of that sort.
Thanks,
LijoQuoted 7 lines
Quoted 7 lines
goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fenceQuoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2958
Quoted 7 lines
__rcu** validations above would invalidate DMABuf imports again. */ ret = process_validate_vms(process_info, &exec.ticket);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-1-if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret);I'd make this a
pr_debugto avoid spamming the log. validation can fail intermittently and rescheduling the worker is there to handle it.With that fixed, the patch is
Reviewed-by Felix Kuehling <[email protected]>Quoted 4 lines
goto validate_map_fail; + } /* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Am 08.03.24 um 17:22 schrieb Mukul Joshi:
Quoted 21 lines
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1@@ -2869,14 +2869,16 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu *mutex_lock (&process_info->lock); -drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES );
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2881
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("Locking VM PD failed, ret: %d\n" , ret); goto ttm_reserve_fail; + }
That's a bad idea. Locking can always be interrupted and that would print an error here.
Regards,
Christian.
Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6
-2}/* Reserve all BOs and page tables/directory. Add all BOs from @@ -2889,8 +2891,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * gobj = &mem->bo->tbo.base; ret =drm_exec_prepare_obj (&exec, gobj,1 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, ret: %d\n" , ret); goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu ** validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret); goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
[AMD Official Use Only - General]
Quoted 36 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, March 11, 2024 2:50 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 08.03.24 um 17:22 schrieb Mukul Joshi:
Quoted 9 lines
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14++++++++++----
Quoted 13 lines
1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*mutex_lock(&process_info->lock);
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2881
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5
-2-drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { + pr_err("Locking VM PD failed, ret: + %d\n", ret); goto ttm_reserve_fail; + }That's a bad idea. Locking can always be interrupted and that would print an error here.
Thanks Christian. Will send out a patch to change it to pr_debug.
Regards,
Mukul
Quoted 35 lines
Regards,
Christian.Quoted 4 lines
} /* Reserve all BOs and page tables/directory. Add allBOs from @@ -2889,8 +2891,10 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 13 lines
gobj = &mem->bo->tbo.base; ret = drm_exec_prepare_obj(&exec, gobj, 1); drm_exec_retry_on_contention(&exec);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-1-if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, + ret: %d\n", ret); goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1* validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret); goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Felix Kuehling
maintainerQuoted 54 lines · Mukul
[AMD Official Use Only - General]
Quoted 36 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, March 11, 2024 2:50 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 08.03.24 um 17:22 schrieb Mukul Joshi:
Quoted 9 lines
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14++++++++++----
Quoted 13 lines
1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*mutex_lock(&process_info->lock);Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu * · line 2881
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5
-2-drm_exec_init (&exec,0 ); +drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {list_for_each_entry (peer_vm, &process_info->vm_list_head, vm_list_node) { ret =amdgpu_vm_lock_pd (peer_vm, &exec,2 );drm_exec_retry_on_contention (&exec); -if (unlikely (ret)) +if (unlikely (ret)) { + pr_err("Locking VM PD failed, ret: + %d\n", ret); goto ttm_reserve_fail; + }That's a bad idea. Locking can always be interrupted and that would print an error here.
Quoted 1 line
Thanks Christian. Will send out a patch to change it to
pr_debug.
We cannot get interrupted here because we're in a worker thread. We should be running in non-interruptible mode.
Regards,
Felix
Quoted 39 lines
Regards,
MukulQuoted 35 lines
Regards,
Christian.Quoted 4 lines
} /* Reserve all BOs and page tables/directory. Add allBOs from @@ -2889,8 +2891,10 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 13 lines
gobj = &mem->bo->tbo.base; ret = drm_exec_prepare_obj(&exec, gobj, 1); drm_exec_retry_on_contention(&exec);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-1-if (unlikely (ret)) +if (unlikely (ret)) { +pr_err ("drm_exec_prepare_obj failed, + ret: %d\n", ret); goto ttm_reserve_fail; + } } }@@ -2950,8 +2954,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1* validations above would invalidate DMABuf imports again. */ ret =process_validate_vms (process_info, &exec.ticket); -if (ret) +if (ret) { +pr_err ("Validating VMs failed, ret: %d\n" , ret); goto validate_map_fail; + }/* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Am 11.03.24 um 16:33 schrieb Felix Kuehling:
Quoted 55 lines · Mukul
Quoted 54 lines
[AMD Official Use Only - General]
Quoted 52 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, March 11, 2024 2:50 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 08.03.24 um 17:22 schrieb Mukul Joshi:
Quoted 9 lines
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c| 14++++++++++----
Quoted 13 lines
1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*
mutex_lock(&process_info->lock);Quoted 13 lines
-
drm_exec_init(&exec, 0);
+drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES);drm_exec_until_all_locked(&exec){list_for_each_entry(peer_vm, &process_info->vm_list_head, vm_list_node){
ret =amdgpu_vm_lock_pd(peer_vm, &exec, 2);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ pr_err("Locking VM PD failed, ret:
+ %d\n", ret);
gotottm_reserve_fail;
+ }That's a bad idea. Locking can always be interrupted and that would print an error here.
Quoted 3 lines
Quoted 1 line
Thanks Christian. Will send out a patch to change it to
pr_debug.We cannot get interrupted here because we're in a worker thread. We should be running in non-interruptible mode.
Ah! Ok in that case this isn't necessary.
But in general I think we should avoid error printing like that. If we want to know where something failed there is a function tracker for that.
Regards,
Christian.
Quoted 44 lines
Regards,
FelixQuoted 39 lines
Regards,
MukulQuoted 35 lines
Regards,
Christian.Quoted 4 lines
}
/* Reserve all BOs and page tables/directory. Add all BOs from @@ -2889,8 +2891,10 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 13 lines
gobj =
&mem->bo->tbo.base;
ret =drm_exec_prepare_obj(&exec, gobj, 1);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ pr_err("drm_exec_prepare_obj failed,
+ ret: %d\n", ret);
gotottm_reserve_fail;
+ }
}
}drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2950,8 +2954,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1* validations above would invalidate DMABuf imports again. */ ret = process_validate_vms(process_info, &exec.ticket); - if (ret) + if (ret) { + pr_err("Validating VMs failed, ret: %d\n", ret); goto validate_map_fail; + } /* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,
Felix Kuehling
maintainerQuoted 56 lines · Christian König
Am 11.03.24 um 16:33 schrieb Felix Kuehling:
Quoted 55 lines · Mukul
Quoted 54 lines
[AMD Official Use Only - General]
Quoted 52 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, March 11, 2024 2:50 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Handle duplicate BOs during process restoreCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 08.03.24 um 17:22 schrieb Mukul Joshi:
Quoted 9 lines
In certain situations, some apps can import a BO multiple times (through IPC for example). To restore such processes successfully, we need to tell drm to ignore duplicate BOs.
While at it, also add additional logging to prevent silent failures when process restore fails.Signed-off-by Mukul Joshi <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c| 14++++++++++----
Quoted 13 lines
1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2869,14 +2869,16 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*
mutex_lock(&process_info->lock);Quoted 13 lines
-
drm_exec_init(&exec, 0);
+drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES);drm_exec_until_all_locked(&exec){list_for_each_entry(peer_vm, &process_info->vm_list_head, vm_list_node){
ret =amdgpu_vm_lock_pd(peer_vm, &exec, 2);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ pr_err("Locking VM PD failed, ret:
+ %d\n", ret);
gotottm_reserve_fail;
+ }That's a bad idea. Locking can always be interrupted and that would print an error here.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Thanks Christian. Will send out a patch to change it to
pr_debug.We cannot get interrupted here because we're in a worker thread. We should be running in non-interruptible mode.
Ah! Ok in that case this isn't necessary.
But in general I think we should avoid error printing like that. If we want to know where something failed there is a function tracker for that.
In this case, it was hard to know that something failed at all. The problem manifested as a soft-hang in an application, and it took several teams several days to track it down to an eviction/restore problem in kernel mode. A failure to reserve BOs seems like the type of problem that is not expected here, and would justify an error or warning message in the kernel log. That would have helped track down this issue much faster.
Regards,
Felix
Quoted 49 lines
Regards,
Christian.Quoted 44 lines
Regards,
FelixQuoted 39 lines
Regards,
MukulQuoted 35 lines
Regards,
Christian.Quoted 4 lines
}
/* Reserve all BOs and page tables/directory. Add all BOs from @@ -2889,8 +2891,10 @@ int
amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int
Quoted 13 lines
gobj =
&mem->bo->tbo.base;
ret =drm_exec_prepare_obj(&exec, gobj, 1);drm_exec_retry_on_contention(&exec);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ pr_err("drm_exec_prepare_obj failed,
+ ret: %d\n", ret);
gotottm_reserve_fail;
+ }
}
}drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2950,8 +2954,10 @@ intamdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct
dma_fence__rcu*Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-1* validations above would invalidate DMABuf imports again. */ ret = process_validate_vms(process_info, &exec.ticket); - if (ret) + if (ret) { + pr_err("Validating VMs failed, ret: %d\n", ret); goto validate_map_fail; + } /* Update mappings not managed by KFD */ list_for_each_entry(peer_vm, &process_info->vm_list_head,