diff mbox series

[v4,57/66] mm/mprotect: Use maple tree navigation instead of vma linked list

Message ID 20211201142918.921493-58-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series Introducing the Maple Tree | expand

Commit Message

Liam R. Howlett Dec. 1, 2021, 2:30 p.m. UTC
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 mm/mprotect.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Vlastimil Babka Jan. 20, 2022, 12:23 p.m. UTC | #1
On 12/1/21 15:30, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> 
> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/mprotect.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index e552f5e0ccbd..7af58fd467c6 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -528,6 +528,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  	const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
>  	const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
>  				(prot & PROT_READ);
> +	MA_STATE(mas, &current->mm->mm_mt, start, start);
>  
>  	start = untagged_addr(start);
>  
> @@ -559,7 +560,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  	if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
>  		goto out;
>  
> -	vma = find_vma(current->mm, start);
> +	vma = mas_find(&mas, ULONG_MAX);
>  	error = -ENOMEM;
>  	if (!vma)
>  		goto out;
> @@ -585,7 +586,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  	if (start > vma->vm_start)
>  		prev = vma;
>  	else
> -		prev = vma->vm_prev;
> +		prev = mas_prev(&mas, 0);
>  
>  	for (nstart = start ; ; ) {
>  		unsigned long mask_off_old_flags;
> @@ -647,7 +648,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  		if (nstart >= end)
>  			goto out;
>  
> -		vma = prev->vm_next;
> +		vma = find_vma(current->mm, prev->vm_end);
>  		if (!vma || vma->vm_start != nstart) {
>  			error = -ENOMEM;
>  			goto out;
diff mbox series

Patch

diff --git a/mm/mprotect.c b/mm/mprotect.c
index e552f5e0ccbd..7af58fd467c6 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -528,6 +528,7 @@  static int do_mprotect_pkey(unsigned long start, size_t len,
 	const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
 	const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
 				(prot & PROT_READ);
+	MA_STATE(mas, &current->mm->mm_mt, start, start);
 
 	start = untagged_addr(start);
 
@@ -559,7 +560,7 @@  static int do_mprotect_pkey(unsigned long start, size_t len,
 	if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
 		goto out;
 
-	vma = find_vma(current->mm, start);
+	vma = mas_find(&mas, ULONG_MAX);
 	error = -ENOMEM;
 	if (!vma)
 		goto out;
@@ -585,7 +586,7 @@  static int do_mprotect_pkey(unsigned long start, size_t len,
 	if (start > vma->vm_start)
 		prev = vma;
 	else
-		prev = vma->vm_prev;
+		prev = mas_prev(&mas, 0);
 
 	for (nstart = start ; ; ) {
 		unsigned long mask_off_old_flags;
@@ -647,7 +648,7 @@  static int do_mprotect_pkey(unsigned long start, size_t len,
 		if (nstart >= end)
 			goto out;
 
-		vma = prev->vm_next;
+		vma = find_vma(current->mm, prev->vm_end);
 		if (!vma || vma->vm_start != nstart) {
 			error = -ENOMEM;
 			goto out;