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 || 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 16 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 || r != -ESRCH ) {
This condition is always true.
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 23 lines · Felix Kuehling
Quoted 21 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 +2
-1@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_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)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni, · line 2531
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-3pr_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 || r != -ESRCH) {This condition is always true.
so sure why this condition is always true? kgd2kfd_quiesce_mm can return -ESRCH when it cannot find kfd process correspondent to mni->mm, then above checking will be false, then will not queue restore work item into system_freezable_wq.
Regards
Xiaogang
Quoted 10 lines
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);
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 45 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Xiaogang
Sent: Thursday, October 3, 2024 6:11 PM
To: Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: Re: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removedQuoted 25 lines · Felix Kuehling
Quoted 23 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 +2
-1@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_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 )Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni, · line 2531
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-3pr_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 || r != -ESRCH ) {This condition is always true.
Quoted 4 lines
so sure why this condition is always true?
kgd2kfd_quiesce_mmcan return-ESRCHwhen it cannot find kfd process correspondent tomni->mm, then above checking will be false, then will not queue restore work item intosystem_freezable_wq.
If you expand the 2 conditions, it becomes "if (r !=0 || r != -3)", which will always be true for any value of r.
Kent
Quoted 15 lines
Regards
Xiaogang
Quoted 10 lines
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);
[Public]
My mistake.
Quoted 59 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Russell, Kent
Sent: Friday, October 4, 2024 9:53 AM
To: Chen, Xiaogang <[email protected]>; Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: RE: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removed[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 45 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Xiaogang
Sent: Thursday, October 3, 2024 6:11 PM
To: Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: Re: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removedQuoted 34 lines · Felix Kuehling
Quoted 19 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 || r != -ESRCH ) {This condition is always true.
Quoted 8 lines
Quoted 4 lines
so sure why this condition is always true?
kgd2kfd_quiesce_mmcan return-ESRCHwhen it cannot find kfd process correspondent tomni->mm, then above checking will be false, then will not queue restore work item intosystem_freezable_wq.If you expand the 2 conditions, it becomes "if (r !=0 || r != -3)", which will always be true for any value of r.
I got this wrong. So it's either r==0 or r==-3 (I need some caffeine). The function returns things back up from evict_queues, mqd_destroy, and can eventually return EIO or ETIME in the hqd_destroy function, so r can indeed be different values than 0/-3. Sorry for my confusion here.
Kent
Quoted 17 lines
Kent
Quoted 15 lines
Regards
Xiaogang
Quoted 10 lines
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);
Felix Kuehling
maintainerQuoted 68 lines · Kent
[Public]
My mistake.
Quoted 64 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Russell, Kent
Sent: Friday, October 4, 2024 9:53 AM
To: Chen, Xiaogang <[email protected]>; Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: RE: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removed[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 49 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Xiaogang
Sent: Thursday, October 3, 2024 6:11 PM
To: Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: Re: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removedQuoted 25 lines · Felix Kuehling
Quoted 23 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 +2
-1@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_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 )Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni, · line 2531
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-3pr_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 || r != -ESRCH ) {This condition is always true.
so sure why this condition is always true?
kgd2kfd_quiesce_mmcan return-ESRCHwhen it cannot find kfd process correspondent tomni->mm, then above checking will be false, then will not queue restore work item intosystem_freezable_wq.
Quoted 4 lines
Quoted 3 lines
If you expand the 2 conditions, it becomes "if (r !=0 || r != -3)", which will always be true for any value of r.
I got this wrong. So it's either r==0 or r==-3 (I need some caffeine). The function returns things back up from
evict_queues,mqd_destroy, and can eventually return EIO or ETIME in thehqd_destroyfunction, so r can indeed be different values than 0/-3. Sorry for my confusion here.
It's (r == 0 || r != -3). So yeah, I was wrong, it's not always true. But it's still confusing because (r == 0) is redundant. I guess you could just write
if (r != -ESRCH) {
...
}I don't know if that matches your intention.
Regards,
Felix
Quoted 20 lines
Kent
Quoted 17 lines
Kent
Quoted 15 lines
Regards
Xiaogang
Quoted 10 lines
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 70 lines · Felix Kuehling
Quoted 68 lines · Kent
[Public]
My mistake.
Quoted 64 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Russell, Kent
Sent: Friday, October 4, 2024 9:53 AM
To: Chen, Xiaogang <[email protected]>; Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: RE: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removed[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 43 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Xiaogang
Sent: Thursday, October 3, 2024 6:11 PM
To: Kuehling, Felix <[email protected]>; [email protected]
Cc: Yang, Philip <[email protected]>
Subject: Re: [PATCH v2] drm/amdkfd: not restore userptr buffer if kfd process has been removedQuoted 23 lines · Felix Kuehling
Quoted 22 lines · Xiaogang.Chen
From: Xiaogang Chen <[email protected]>
When kfd process has been terminated not restore userptr buffer after mmu notifier invalidates a range.
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 +1
-1@@ -2524,11 +2524,15 @@ int amdgpu_amdkfd_evict_userptr(structmmu_interval_notifier *mni,/* First eviction, stop the queues */ r =kgd2kfd_quiesce_mm (mni->mm,KFD_QUEUE_EVICTION_TRIGGER_USERPTR ); -if (r) +Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni, · line 2531
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3
-3+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 || r != -ESRCH ) {This condition is always true.
Quoted 4 lines
so sure why this condition is always true?
kgd2kfd_quiesce_mmcan return-ESRCHwhen it cannot find kfd process correspondent tomni->mm, then above checking will be false, then will not queue restore work item intosystem_freezable_wq.If you expand the 2 conditions, it becomes "if (r !=0 || r != -3)", which will always be true for any value of r.
Quoted 8 lines
Quoted 1 line
I got this wrong. So it's either r==0 or r==-3 (I need some caffeine). The function returns things back up from
evict_queues,mqd_destroy, and can eventually return EIO or ETIME in thehqd_destroyfunction, so r can indeed be different values than 0/-3. Sorry for my confusion here.It's (r == 0 || r != -3). So yeah, I was wrong, it's not always true. But it's still confusing because (r == 0) is redundant. I guess you could just write
if (r != -ESRCH) { ... }I don't know if that matches your intention.
Yes, the condition check confused people though not wrong. My thought was: when there is no error, or the error is not -3, do userptr restore. So only when error is -3, not do userptr restore.
I will send new one to simply it.
Thanks
Xiaogang
Quoted 22 lines
Regards,
FelixQuoted 18 lines
Kent
Quoted 16 lines
Kent
Quoted 14 lines
Regards
Xiaogang
Quoted 10 lines
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);