[PATCH 1/2] drm/amdkfd: Use mmget_not_zero in MMU notifier

Felix Kuehling felix.kuehling at amd.com
Mon May 30 16:03:57 UTC 2022


Am 2022-05-30 um 10:57 schrieb Philip Yang:
> MMU notifier callback may pass in mm with mm->mm_users==0 when process
> is exiting, use mmget_no_zero to avoid accessing invalid mm in deferred
> list work after mm is gone.
>
> Signed-off-by: Philip Yang <Philip.Yang at amd.com>

Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 835b5187f0b8..2ba3de0fb8aa 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -2307,6 +2307,8 @@ svm_range_cpu_invalidate_pagetables(struct mmu_interval_notifier *mni,
>   
>   	if (range->event == MMU_NOTIFY_RELEASE)
>   		return true;
> +	if (!mmget_not_zero(mni->mm))
> +		return true;
>   
>   	start = mni->interval_tree.start;
>   	last = mni->interval_tree.last;
> @@ -2333,6 +2335,7 @@ svm_range_cpu_invalidate_pagetables(struct mmu_interval_notifier *mni,
>   	}
>   
>   	svm_range_unlock(prange);
> +	mmput(mni->mm);
>   
>   	return true;
>   }


More information about the amd-gfx mailing list