LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
@ 2022-10-07  2:26 Deming Wang
  2022-10-20 16:47 ` Felix Kuehling
  0 siblings, 1 reply; 8+ messages in thread
From: Deming Wang @ 2022-10-07  2:26 UTC (permalink / raw
  To: airlied, daniel, Felix.Kuehling, alexander.deucher,
	christian.koenig, Xinhui.Pan
  Cc: amd-gfx, dri-devel, linux-kernel, Deming Wang

Using vma_lookup() verifies the start address is contained in the found
vma.  This results in easier to read the code.

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 2797029bd500..3599cc931b0a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -529,8 +529,8 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,
 	for (addr = start; addr < end;) {
 		unsigned long next;
 
-		vma = find_vma(mm, addr);
-		if (!vma || addr < vma->vm_start)
+		vma = vma_lookup(mm, addr);
+		if (!vma)
 			break;
 
 		next = min(vma->vm_end, end);
@@ -798,8 +798,8 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,
 	for (addr = start; addr < end;) {
 		unsigned long next;
 
-		vma = find_vma(mm, addr);
-		if (!vma || addr < vma->vm_start) {
+		vma = vma_lookup(mm, addr)
+		if (!vma) {
 			pr_debug("failed to find vma for prange %p\n", prange);
 			r = -EFAULT;
 			break;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
@ 2022-10-07  2:48 Deming Wang
  2022-10-17 19:35 ` Felix Kuehling
  0 siblings, 1 reply; 8+ messages in thread
From: Deming Wang @ 2022-10-07  2:48 UTC (permalink / raw
  To: airlied, daniel, Felix.Kuehling, alexander.deucher,
	christian.koenig, Xinhui.Pan
  Cc: amd-gfx, dri-devel, linux-kernel, Deming Wang

Using vma_lookup() verifies the start address is contained in the found
vma.  This results in easier to read the code.

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 64fdf63093a0..cabcc2ca3c23 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
 		unsigned long npages;
 		bool readonly;
 
-		vma = find_vma(mm, addr);
-		if (!vma || addr < vma->vm_start) {
+		vma = vma_lookup(mm, addr);
+		if (!vma) {
 			r = -EFAULT;
 			goto unreserve_out;
 		}
@@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
 	struct interval_tree_node *node;
 	unsigned long start_limit, end_limit;
 
-	vma = find_vma(p->mm, addr << PAGE_SHIFT);
-	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
+	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
+	if (!vma) {
 		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
 		return -EFAULT;
 	}
@@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,
 	/* __do_munmap removed VMA, return success as we are handling stale
 	 * retry fault.
 	 */
-	vma = find_vma(mm, addr << PAGE_SHIFT);
-	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
+	vma = vma_lookup(mm, addr << PAGE_SHIFT);
+	if (!vma) {
 		pr_debug("address 0x%llx VMA is removed\n", addr);
 		r = 0;
 		goto out_unlock_range;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
  2022-10-07  2:48 [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma() Deming Wang
@ 2022-10-17 19:35 ` Felix Kuehling
  2022-10-18  0:47   ` 答复: " tomorrow Wang (王德明)
  0 siblings, 1 reply; 8+ messages in thread
From: Felix Kuehling @ 2022-10-17 19:35 UTC (permalink / raw
  To: Deming Wang, airlied, daniel, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, linux-kernel


On 2022-10-06 22:48, Deming Wang wrote:
> Using vma_lookup() verifies the start address is contained in the found
> vma.  This results in easier to read the code.

Thank you for the patches. This and your other patch look good to me. 
However, you missed one use of find_vma in svm_range_is_valid. Is that 
an oversight or is there a reason why we need to use find_vma there?

If you're going to respin it, you may also squash the two patches into one.

Thanks,
   Felix


>
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 64fdf63093a0..cabcc2ca3c23 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
>   		unsigned long npages;
>   		bool readonly;
>   
> -		vma = find_vma(mm, addr);
> -		if (!vma || addr < vma->vm_start) {
> +		vma = vma_lookup(mm, addr);
> +		if (!vma) {
>   			r = -EFAULT;
>   			goto unreserve_out;
>   		}
> @@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
>   	struct interval_tree_node *node;
>   	unsigned long start_limit, end_limit;
>   
> -	vma = find_vma(p->mm, addr << PAGE_SHIFT);
> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> +	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
> +	if (!vma) {
>   		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
>   		return -EFAULT;
>   	}
> @@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,
>   	/* __do_munmap removed VMA, return success as we are handling stale
>   	 * retry fault.
>   	 */
> -	vma = find_vma(mm, addr << PAGE_SHIFT);
> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> +	vma = vma_lookup(mm, addr << PAGE_SHIFT);
> +	if (!vma) {
>   		pr_debug("address 0x%llx VMA is removed\n", addr);
>   		r = 0;
>   		goto out_unlock_range;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 答复: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
  2022-10-17 19:35 ` Felix Kuehling
@ 2022-10-18  0:47   ` tomorrow Wang (王德明)
  2022-10-19 14:21     ` Felix Kuehling
  0 siblings, 1 reply; 8+ messages in thread
From: tomorrow Wang (王德明) @ 2022-10-18  0:47 UTC (permalink / raw
  To: felix.kuehling@amd.com
  Cc: airlied@gmail.com, daniel@ffwll.ch, alexander.deucher@amd.com,
	christian.koenig@amd.com, Xinhui.Pan@amd.com,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 3007 bytes --]

Hi,
The function vma_lookup show below.  Vma valid check is included in it. Or, What other questions do you have?

static inline
struct vm_area_struct *vma_lookup(struct mm_struct *mm, unsigned long addr)
 {
         struct vm_area_struct *vma = find_vma(mm, addr);

         if (vma && addr < vma->vm_start)
                 vma = NULL;

         return vma;
 }


> from: Felix Kuehling <felix.kuehling@amd.com>
> time: 2022年10月18日 3:35
> to: tomorrow Wang (王德明) <wangdeming@inspur.com>;
> airlied@gmail.com; daniel@ffwll.ch; alexander.deucher@amd.com;
> christian.koenig@amd.com; Xinhui.Pan@amd.com
> linux-kernel@vger.kernel.org
> sub: Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
> 
> 
> On 2022-10-06 22:48, Deming Wang wrote:
> > Using vma_lookup() verifies the start address is contained in the
> > found vma.  This results in easier to read the code.
> 
> Thank you for the patches. This and your other patch look good to me.
> However, you missed one use of find_vma in svm_range_is_valid. Is that an
> oversight or is there a reason why we need to use find_vma there?
> 
> If you're going to respin it, you may also squash the two patches into one.
> 
> Thanks,
>    Felix
> 
> 
> >
> > Signed-off-by: Deming Wang <wangdeming@inspur.com>
> > ---
> >   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > index 64fdf63093a0..cabcc2ca3c23 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > @@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct
> mm_struct *mm,
> >   		unsigned long npages;
> >   		bool readonly;
> >
> > -		vma = find_vma(mm, addr);
> > -		if (!vma || addr < vma->vm_start) {
> > +		vma = vma_lookup(mm, addr);
> > +		if (!vma) {
> >   			r = -EFAULT;
> >   			goto unreserve_out;
> >   		}
> > @@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct
> kfd_process *p, int64_t addr,
> >   	struct interval_tree_node *node;
> >   	unsigned long start_limit, end_limit;
> >
> > -	vma = find_vma(p->mm, addr << PAGE_SHIFT);
> > -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> > +	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
> > +	if (!vma) {
> >   		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
> >   		return -EFAULT;
> >   	}
> > @@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device
> *adev, unsigned int pasid,
> >   	/* __do_munmap removed VMA, return success as we are handling stale
> >   	 * retry fault.
> >   	 */
> > -	vma = find_vma(mm, addr << PAGE_SHIFT);
> > -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> > +	vma = vma_lookup(mm, addr << PAGE_SHIFT);
> > +	if (!vma) {
> >   		pr_debug("address 0x%llx VMA is removed\n", addr);
> >   		r = 0;
> >   		goto out_unlock_range;

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3780 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 答复: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
  2022-10-18  0:47   ` 答复: " tomorrow Wang (王德明)
@ 2022-10-19 14:21     ` Felix Kuehling
  0 siblings, 0 replies; 8+ messages in thread
From: Felix Kuehling @ 2022-10-19 14:21 UTC (permalink / raw
  To: tomorrow Wang (王德明)
  Cc: airlied@gmail.com, daniel@ffwll.ch, alexander.deucher@amd.com,
	christian.koenig@amd.com, Xinhui.Pan@amd.com,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org


Am 2022-10-17 um 20:47 schrieb tomorrow Wang (王德明):
> Hi,
> The function vma_lookup show below.  Vma valid check is included in it. Or, What other questions do you have?

My question is, why did you leave the find_vma call in 
svm_range_is_valid unchanged? I don't see a technical reason, but maybe 
I'm missing something. If there is a reason, please explain. If there is 
no reason, please fix that place as well for consistency.

Thanks,
   Felix


>
> static inline
> struct vm_area_struct *vma_lookup(struct mm_struct *mm, unsigned long addr)
>   {
>           struct vm_area_struct *vma = find_vma(mm, addr);
>
>           if (vma && addr < vma->vm_start)
>                   vma = NULL;
>
>           return vma;
>   }
>
>
>> from: Felix Kuehling <felix.kuehling@amd.com>
>> time: 2022年10月18日 3:35
>> to: tomorrow Wang (王德明) <wangdeming@inspur.com>;
>> airlied@gmail.com; daniel@ffwll.ch; alexander.deucher@amd.com;
>> christian.koenig@amd.com; Xinhui.Pan@amd.com
>> linux-kernel@vger.kernel.org
>> sub: Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
>>
>>
>> On 2022-10-06 22:48, Deming Wang wrote:
>>> Using vma_lookup() verifies the start address is contained in the
>>> found vma.  This results in easier to read the code.
>> Thank you for the patches. This and your other patch look good to me.
>> However, you missed one use of find_vma in svm_range_is_valid. Is that an
>> oversight or is there a reason why we need to use find_vma there?
>>
>> If you're going to respin it, you may also squash the two patches into one.
>>
>> Thanks,
>>     Felix
>>
>>
>>> Signed-off-by: Deming Wang <wangdeming@inspur.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> index 64fdf63093a0..cabcc2ca3c23 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> @@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct
>> mm_struct *mm,
>>>    		unsigned long npages;
>>>    		bool readonly;
>>>
>>> -		vma = find_vma(mm, addr);
>>> -		if (!vma || addr < vma->vm_start) {
>>> +		vma = vma_lookup(mm, addr);
>>> +		if (!vma) {
>>>    			r = -EFAULT;
>>>    			goto unreserve_out;
>>>    		}
>>> @@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct
>> kfd_process *p, int64_t addr,
>>>    	struct interval_tree_node *node;
>>>    	unsigned long start_limit, end_limit;
>>>
>>> -	vma = find_vma(p->mm, addr << PAGE_SHIFT);
>>> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
>>> +	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
>>> +	if (!vma) {
>>>    		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
>>>    		return -EFAULT;
>>>    	}
>>> @@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device
>> *adev, unsigned int pasid,
>>>    	/* __do_munmap removed VMA, return success as we are handling stale
>>>    	 * retry fault.
>>>    	 */
>>> -	vma = find_vma(mm, addr << PAGE_SHIFT);
>>> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
>>> +	vma = vma_lookup(mm, addr << PAGE_SHIFT);
>>> +	if (!vma) {
>>>    		pr_debug("address 0x%llx VMA is removed\n", addr);
>>>    		r = 0;
>>>    		goto out_unlock_range;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
@ 2022-10-20  8:20 Deming Wang
  2022-10-20 16:50 ` Felix Kuehling
  0 siblings, 1 reply; 8+ messages in thread
From: Deming Wang @ 2022-10-20  8:20 UTC (permalink / raw
  To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel
  Cc: amd-gfx, dri-devel, linux-kernel, Deming Wang

Using vma_lookup() verifies the start address is contained in the found
vma.  This results in easier to read the code.

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 64fdf63093a0..0100812478b2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
 		unsigned long npages;
 		bool readonly;
 
-		vma = find_vma(mm, addr);
-		if (!vma || addr < vma->vm_start) {
+		vma = vma_lookup(mm, addr);
+		if (!vma) {
 			r = -EFAULT;
 			goto unreserve_out;
 		}
@@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
 	struct interval_tree_node *node;
 	unsigned long start_limit, end_limit;
 
-	vma = find_vma(p->mm, addr << PAGE_SHIFT);
-	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
+	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
+	if (!vma) {
 		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
 		return -EFAULT;
 	}
@@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,
 	/* __do_munmap removed VMA, return success as we are handling stale
 	 * retry fault.
 	 */
-	vma = find_vma(mm, addr << PAGE_SHIFT);
-	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
+	vma = vma_lookup(mm, addr << PAGE_SHIFT);
+	if (!vma) {
 		pr_debug("address 0x%llx VMA is removed\n", addr);
 		r = 0;
 		goto out_unlock_range;
@@ -3152,9 +3152,8 @@ svm_range_is_valid(struct kfd_process *p, uint64_t start, uint64_t size)
 	start <<= PAGE_SHIFT;
 	end = start + (size << PAGE_SHIFT);
 	do {
-		vma = find_vma(p->mm, start);
-		if (!vma || start < vma->vm_start ||
-		    (vma->vm_flags & device_vma))
+		vma = vma_lookup(p->mm, start);
+		if (!vma || (vma->vm_flags & device_vma))
 			return -EFAULT;
 		start = min(end, vma->vm_end);
 	} while (start < end);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
  2022-10-07  2:26 Deming Wang
@ 2022-10-20 16:47 ` Felix Kuehling
  0 siblings, 0 replies; 8+ messages in thread
From: Felix Kuehling @ 2022-10-20 16:47 UTC (permalink / raw
  To: Deming Wang, airlied, daniel, alexander.deucher, christian.koenig,
	Xinhui.Pan
  Cc: amd-gfx, dri-devel, linux-kernel

Am 2022-10-06 um 22:26 schrieb Deming Wang:
> Using vma_lookup() verifies the start address is contained in the found
> vma.  This results in easier to read the code.
>
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 2797029bd500..3599cc931b0a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -529,8 +529,8 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,
>   	for (addr = start; addr < end;) {
>   		unsigned long next;
>   
> -		vma = find_vma(mm, addr);
> -		if (!vma || addr < vma->vm_start)
> +		vma = vma_lookup(mm, addr);
> +		if (!vma)
>   			break;
>   
>   		next = min(vma->vm_end, end);
> @@ -798,8 +798,8 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,
>   	for (addr = start; addr < end;) {
>   		unsigned long next;
>   
> -		vma = find_vma(mm, addr);
> -		if (!vma || addr < vma->vm_start) {
> +		vma = vma_lookup(mm, addr)

There is a semicolon missing here. I will fix this before I submit the 
patch.

Please do at least a minimum amount of due diligence before posting 
patches. That would include a test to make sure your code compiles.

Regards,
   Felix


> +		if (!vma) {
>   			pr_debug("failed to find vma for prange %p\n", prange);
>   			r = -EFAULT;
>   			break;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma()
  2022-10-20  8:20 Deming Wang
@ 2022-10-20 16:50 ` Felix Kuehling
  0 siblings, 0 replies; 8+ messages in thread
From: Felix Kuehling @ 2022-10-20 16:50 UTC (permalink / raw
  To: Deming Wang, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel
  Cc: amd-gfx, dri-devel, linux-kernel

Am 2022-10-20 um 04:20 schrieb Deming Wang:
> Using vma_lookup() verifies the start address is contained in the found
> vma.  This results in easier to read the code.
>
> Signed-off-by: Deming Wang <wangdeming@inspur.com>

Thank you. This patch is

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

I squashed it with your earlier patch in kfd_migrate.c and submitted it 
to our amd-staging-drm-next branch.

Regards,
   Felix


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 17 ++++++++---------
>   1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 64fdf63093a0..0100812478b2 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
>   		unsigned long npages;
>   		bool readonly;
>   
> -		vma = find_vma(mm, addr);
> -		if (!vma || addr < vma->vm_start) {
> +		vma = vma_lookup(mm, addr);
> +		if (!vma) {
>   			r = -EFAULT;
>   			goto unreserve_out;
>   		}
> @@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
>   	struct interval_tree_node *node;
>   	unsigned long start_limit, end_limit;
>   
> -	vma = find_vma(p->mm, addr << PAGE_SHIFT);
> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> +	vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
> +	if (!vma) {
>   		pr_debug("VMA does not exist in address [0x%llx]\n", addr);
>   		return -EFAULT;
>   	}
> @@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,
>   	/* __do_munmap removed VMA, return success as we are handling stale
>   	 * retry fault.
>   	 */
> -	vma = find_vma(mm, addr << PAGE_SHIFT);
> -	if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) {
> +	vma = vma_lookup(mm, addr << PAGE_SHIFT);
> +	if (!vma) {
>   		pr_debug("address 0x%llx VMA is removed\n", addr);
>   		r = 0;
>   		goto out_unlock_range;
> @@ -3152,9 +3152,8 @@ svm_range_is_valid(struct kfd_process *p, uint64_t start, uint64_t size)
>   	start <<= PAGE_SHIFT;
>   	end = start + (size << PAGE_SHIFT);
>   	do {
> -		vma = find_vma(p->mm, start);
> -		if (!vma || start < vma->vm_start ||
> -		    (vma->vm_flags & device_vma))
> +		vma = vma_lookup(p->mm, start);
> +		if (!vma || (vma->vm_flags & device_vma))
>   			return -EFAULT;
>   		start = min(end, vma->vm_end);
>   	} while (start < end);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-20 16:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07  2:48 [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma() Deming Wang
2022-10-17 19:35 ` Felix Kuehling
2022-10-18  0:47   ` 答复: " tomorrow Wang (王德明)
2022-10-19 14:21     ` Felix Kuehling
  -- strict thread matches above, loose matches on Subject: below --
2022-10-20  8:20 Deming Wang
2022-10-20 16:50 ` Felix Kuehling
2022-10-07  2:26 Deming Wang
2022-10-20 16:47 ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).