drm/amdkfd: Not restore userptr buffer if kfd process has been removed
Subsystems (3)
PATCH v2 1/1 drm/amdkfd: Not restore userptr buffer if kfd process has been removed
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +8 -4
@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni,/* First eviction, stop the queues */ r =kgd2kfd_quiesce_mm (mni->mm,KFD_QUEUE_EVICTION_TRIGGER_USERPTR ); -if (r) + +if (r && r != -ESRCH )pr_err ("Failed to quiesce KFD\n" ); -queue_delayed_work (system_freezable_wq, - &process_info->restore_userptr_work, -msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + +if (r != -ESRCH ) { +queue_delayed_work (system_freezable_wq, + &process_info->restore_userptr_work, +msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + } }mutex_unlock (&process_info->notifier_lock);
Signature · 1 line
2.25.1
Felix Kuehling
maintainerQuoted 4 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
Is this fixing a real problem or a hypothetical problem? If there is a real problem, can you include more information here? It looks to me that amdgpu_amdkfd_restore_userptr_worker is already handling the cases where a process or mm_struct no longer exists. Maybe the only user visible change from this patch is, that you no longer print "Failed to quiesce KFD" in a corner case of an MMU notifier for a process that no longer exists?
Or is there a problem with the lifetime of the process_info that contains the work_struct?
Quoted 13 lines
Signed-off-by Xiaogang Chen<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni,/* First eviction, stop the queues */ r = kgd2kfd_quiesce_mm(mni->mm,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni, · line 2531
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-4KFD_QUEUE_EVICTION_TRIGGER_USERPTR); -if (r) + +if (r && r != -ESRCH )pr_err ("Failed to quiesce KFD\n" ); -queue_delayed_work (system_freezable_wq, - &process_info->restore_userptr_work, -msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + +if (r != -ESRCH ) {
Braces are not required because there is only one statement inside the if.
Regards,
Felix
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-0+queue_delayed_work (system_freezable_wq, + &process_info->restore_userptr_work, +msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + } }mutex_unlock (&process_info->notifier_lock);
Quoted 11 lines · Felix Kuehling
Quoted 4 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
Is this fixing a real problem or a hypothetical problem? If there is a real problem, can you include more information here? It looks to me that
amdgpu_amdkfd_restore_userptr_workeris already handling the cases where a process ormm_structno longer exists. Maybe the only user visible change from this patch is, that you no longer print "Failed to quiesce KFD" in a corner case of an MMU notifier for a process that no longer exists?Or is there a problem with the lifetime of the
process_infothat contains thework_struct?
My thought was that restore userptr buffer is not needed anyway if the correspondent kfd process has been removed. I noticed that during another work. I do not see if still restoring userptr buffer would cause issue when the kfd process not exist. Think avoid doing it is safer, and not see there is regression.
Regards
Xiaogang
Quoted 38 lines
Quoted 15 lines
Signed-off-by Xiaogang Chen<[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_interval_notifier *mni, /* First eviction, stop the queues */ r = kgd2kfd_quiesce_mm(mni->mm,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct · line 2532
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-4KFD_QUEUE_EVICTION_TRIGGER_USERPTR); - if (r) + + if (r && r != -ESRCH) pr_err("Failed to quiesce KFD\n"); - queue_delayed_work(system_freezable_wq, - &process_info->restore_userptr_work, - msecs_to_jiffies(AMDGPU_USERPTR_RESTORE_DELAY_MS)); + + if (r != -ESRCH) {Braces are not required because there is only one statement inside the if.
Regards,
FelixQuoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-0+queue_delayed_work (system_freezable_wq, + &process_info->restore_userptr_work, +msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + } } mutex_unlock(&process_info->notifier_lock);
Quoted 6 lines · Xiaogang
Quoted 4 lines · Felix Kuehling
Quoted 2 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
Is this fixing a real problem or a hypothetical problem? If there is a real problem, can you include more information here? It looks to me that
amdgpu_amdkfd_restore_userptr_workeris already handling the cases where a process ormm_structno longer exists. Maybe the only user visible change from this patch is, that you no longer print "Failed to quiesce KFD" in a corner case of an MMU notifier for a process that no longer exists?Or is there a problem with the lifetime of the
process_infothat contains thework_struct?My thought was that restore userptr buffer is not needed anyway if the correspondent kfd process has been removed. I noticed that during another work. I do not see if still restoring userptr buffer would cause issue when the kfd process not exist. Think avoid doing it is safer, and not see there is regression.
Well, safer is usually not to change things that aren't broken. Anyway, this seems reasonable enough. With the braces below removed, the patch is
Quoted 43 lines
Regards
Xiaogang
Quoted 38 lines
Quoted 15 lines
Signed-off-by Xiaogang Chen<[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_interval_notifier *mni, /* First eviction, stop the queues */ r = kgd2kfd_quiesce_mm(mni->mm,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct · line 2532
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-4KFD_QUEUE_EVICTION_TRIGGER_USERPTR); - if (r) + + if (r && r != -ESRCH) pr_err("Failed to quiesce KFD\n"); - queue_delayed_work(system_freezable_wq, - &process_info->restore_userptr_work, -msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + + if (r != -ESRCH) {Braces are not required because there is only one statement inside the if.
Regards,
FelixQuoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +4
-0+queue_delayed_work (system_freezable_wq, + &process_info->restore_userptr_work, +msecs_to_jiffies (AMDGPU_USERPTR_RESTORE_DELAY_MS )); + } } mutex_unlock(&process_info->notifier_lock);