All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages()
@ 2021-02-23 23:50 Liam Howlett
  2021-02-24  2:49 ` Matthew Wilcox
  2021-02-24 10:13 ` David Hildenbrand
  0 siblings, 2 replies; 3+ messages in thread
From: Liam Howlett @ 2021-02-23 23:50 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Hugh Dickins, Liam Howlett

Since this call uses MAP_FIXED, do_mmap() will munlock the necessary
range.  There is also an error in the loop test expression which will
evaluate as false and the loop body has never execute.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Hugh Dickins <hughd@google.com>
---
 mm/mmap.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index dc7206032387c..e22b048733269 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3025,25 +3025,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
 
 	flags &= MAP_NONBLOCK;
 	flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
-	if (vma->vm_flags & VM_LOCKED) {
-		struct vm_area_struct *tmp;
+	if (vma->vm_flags & VM_LOCKED)
 		flags |= MAP_LOCKED;
 
-		/* drop PG_Mlocked flag for over-mapped range */
-		for (tmp = vma; tmp->vm_start >= start + size;
-				tmp = tmp->vm_next) {
-			/*
-			 * Split pmd and munlock page on the border
-			 * of the range.
-			 */
-			vma_adjust_trans_huge(tmp, start, start + size, 0);
-
-			munlock_vma_pages_range(tmp,
-					max(tmp->vm_start, start),
-					min(tmp->vm_end, start + size));
-		}
-	}
-
 	file = get_file(vma->vm_file);
 	ret = do_mmap(vma->vm_file, start, size,
 			prot, flags, pgoff, &populate, NULL);
-- 
2.30.0

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

* Re: [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages()
  2021-02-23 23:50 [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages() Liam Howlett
@ 2021-02-24  2:49 ` Matthew Wilcox
  2021-02-24 10:13 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2021-02-24  2:49 UTC (permalink / raw)
  To: Liam Howlett; +Cc: Andrew Morton, linux-mm, linux-kernel, Hugh Dickins

On Tue, Feb 23, 2021 at 11:50:23PM +0000, Liam Howlett wrote:
> Since this call uses MAP_FIXED, do_mmap() will munlock the necessary
> range.  There is also an error in the loop test expression which will
> evaluate as false and the loop body has never execute.
> 
> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> Acked-by: Hugh Dickins <hughd@google.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

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

* Re: [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages()
  2021-02-23 23:50 [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages() Liam Howlett
  2021-02-24  2:49 ` Matthew Wilcox
@ 2021-02-24 10:13 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2021-02-24 10:13 UTC (permalink / raw)
  To: Liam Howlett, Andrew Morton; +Cc: linux-mm, linux-kernel, Hugh Dickins

On 24.02.21 00:50, Liam Howlett wrote:
> Since this call uses MAP_FIXED, do_mmap() will munlock the necessary
> range.  There is also an error in the loop test expression which will
> evaluate as false and the loop body has never execute.
> 
> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> Acked-by: Hugh Dickins <hughd@google.com>
> ---
>   mm/mmap.c | 18 +-----------------
>   1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index dc7206032387c..e22b048733269 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -3025,25 +3025,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
>   
>   	flags &= MAP_NONBLOCK;
>   	flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
> -	if (vma->vm_flags & VM_LOCKED) {
> -		struct vm_area_struct *tmp;
> +	if (vma->vm_flags & VM_LOCKED)
>   		flags |= MAP_LOCKED;
>   
> -		/* drop PG_Mlocked flag for over-mapped range */
> -		for (tmp = vma; tmp->vm_start >= start + size;
> -				tmp = tmp->vm_next) {
> -			/*
> -			 * Split pmd and munlock page on the border
> -			 * of the range.
> -			 */
> -			vma_adjust_trans_huge(tmp, start, start + size, 0);
> -
> -			munlock_vma_pages_range(tmp,
> -					max(tmp->vm_start, start),
> -					min(tmp->vm_end, start + size));
> -		}
> -	}
> -
>   	file = get_file(vma->vm_file);
>   	ret = do_mmap(vma->vm_file, start, size,
>   			prot, flags, pgoff, &populate, NULL);
> 

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

-- 
Thanks,

David / dhildenb


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

end of thread, other threads:[~2021-02-24 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 23:50 [PATCH v3] mm/mmap: Don't unlock VMAs in remap_file_pages() Liam Howlett
2021-02-24  2:49 ` Matthew Wilcox
2021-02-24 10:13 ` David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.