linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/madvise: Use vma_lookup() instead of find_vma()
@ 2022-03-11  8:27 Miaohe Lin
  2022-03-11  9:55 ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: Miaohe Lin @ 2022-03-11  8:27 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 5b6d796e55de..afd68bfc77d4 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -883,8 +883,8 @@ static long madvise_populate(struct vm_area_struct *vma,
 		 * our VMA might have been split.
 		 */
 		if (!vma || start >= vma->vm_end) {
-			vma = find_vma(mm, start);
-			if (!vma || start < vma->vm_start)
+			vma = vma_lookup(mm, start);
+			if (!vma)
 				return -ENOMEM;
 		}
 
-- 
2.23.0



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

* Re: [PATCH] mm/madvise: Use vma_lookup() instead of find_vma()
  2022-03-11  8:27 [PATCH] mm/madvise: Use vma_lookup() instead of find_vma() Miaohe Lin
@ 2022-03-11  9:55 ` David Hildenbrand
  0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2022-03-11  9:55 UTC (permalink / raw)
  To: Miaohe Lin, akpm; +Cc: linux-mm, linux-kernel

On 11.03.22 09:27, Miaohe Lin wrote:
> Using vma_lookup() verifies the start address is contained in the found
> vma. This results in easier to read the code.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/madvise.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 5b6d796e55de..afd68bfc77d4 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -883,8 +883,8 @@ static long madvise_populate(struct vm_area_struct *vma,
>  		 * our VMA might have been split.
>  		 */
>  		if (!vma || start >= vma->vm_end) {
> -			vma = find_vma(mm, start);
> -			if (!vma || start < vma->vm_start)
> +			vma = vma_lookup(mm, start);
> +			if (!vma)
>  				return -ENOMEM;
>  		}
>  

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



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

* Re: [PATCH] mm/madvise: Use vma_lookup() instead of find_vma()
  2023-04-04  9:45 Peng Zhang
@ 2023-04-05 17:19 ` Liam R. Howlett
  0 siblings, 0 replies; 4+ messages in thread
From: Liam R. Howlett @ 2023-04-05 17:19 UTC (permalink / raw)
  To: Peng Zhang; +Cc: linux-mm, linux-kernel, akpm, wangkefeng.wang, sunnanyong

* Peng Zhang <zhangpeng362@huawei.com> [230404 05:45]:
> From: ZhangPeng <zhangpeng362@huawei.com>
> 
> Using vma_lookup() verifies the address is contained in the found vma.
> This results in easier to read the code.
> 
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>

Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>

> ---
>  mm/madvise.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 340125d08c03..405a2c4a0a18 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -852,21 +852,9 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
>  		*prev = NULL; /* mmap_lock has been dropped, prev is stale */
>  
>  		mmap_read_lock(mm);
> -		vma = find_vma(mm, start);
> +		vma = vma_lookup(mm, start);
>  		if (!vma)
>  			return -ENOMEM;
> -		if (start < vma->vm_start) {
> -			/*
> -			 * This "vma" under revalidation is the one
> -			 * with the lowest vma->vm_start where start
> -			 * is also < vma->vm_end. If start <
> -			 * vma->vm_start it means an hole materialized
> -			 * in the user address space within the
> -			 * virtual range passed to MADV_DONTNEED
> -			 * or MADV_FREE.
> -			 */
> -			return -ENOMEM;
> -		}
>  		/*
>  		 * Potential end adjustment for hugetlb vma is OK as
>  		 * the check below keeps end within vma.
> -- 
> 2.25.1
> 
> 


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

* [PATCH] mm/madvise: Use vma_lookup() instead of find_vma()
@ 2023-04-04  9:45 Peng Zhang
  2023-04-05 17:19 ` Liam R. Howlett
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Zhang @ 2023-04-04  9:45 UTC (permalink / raw)
  To: linux-mm, linux-kernel, akpm; +Cc: wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

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

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/madvise.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 340125d08c03..405a2c4a0a18 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -852,21 +852,9 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
 		*prev = NULL; /* mmap_lock has been dropped, prev is stale */
 
 		mmap_read_lock(mm);
-		vma = find_vma(mm, start);
+		vma = vma_lookup(mm, start);
 		if (!vma)
 			return -ENOMEM;
-		if (start < vma->vm_start) {
-			/*
-			 * This "vma" under revalidation is the one
-			 * with the lowest vma->vm_start where start
-			 * is also < vma->vm_end. If start <
-			 * vma->vm_start it means an hole materialized
-			 * in the user address space within the
-			 * virtual range passed to MADV_DONTNEED
-			 * or MADV_FREE.
-			 */
-			return -ENOMEM;
-		}
 		/*
 		 * Potential end adjustment for hugetlb vma is OK as
 		 * the check below keeps end within vma.
-- 
2.25.1



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

end of thread, other threads:[~2023-04-05 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11  8:27 [PATCH] mm/madvise: Use vma_lookup() instead of find_vma() Miaohe Lin
2022-03-11  9:55 ` David Hildenbrand
2023-04-04  9:45 Peng Zhang
2023-04-05 17:19 ` Liam R. Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox