diff mbox series

[v11,3/3] mm: unmap VM_PFNMAP mappings with optimized path

Message ID 1537376621-51150-4-git-send-email-yang.shi@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series mm: zap pages with read mmap_sem in munmap for large mapping | expand

Commit Message

Yang Shi Sept. 19, 2018, 5:03 p.m. UTC
When unmapping VM_PFNMAP mappings, vm flags need to be updated. Since
the vmas have been detached, so it sounds safe to update vm flags with
read mmap_sem.

Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
 mm/mmap.c | 9 ---------
 1 file changed, 9 deletions(-)

Comments

Vlastimil Babka Sept. 26, 2018, 11:11 a.m. UTC | #1
On 9/19/18 7:03 PM, Yang Shi wrote:
> When unmapping VM_PFNMAP mappings, vm flags need to be updated. Since
> the vmas have been detached, so it sounds safe to update vm flags with
> read mmap_sem.
> 
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Reviewed-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
> ---
>  mm/mmap.c | 9 ---------
>  1 file changed, 9 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 490340e..847a17d 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2771,15 +2771,6 @@ static int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
>  				munlock_vma_pages_all(tmp);
>  			}
>  
> -			/*
> -			 * Unmapping vmas, which have VM_HUGETLB or VM_PFNMAP,

Ah, the comment should have been already updated with the previous
patch. But nevermind as that all goes away.

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

> -			 * need get done with write mmap_sem held since they may
> -			 * update vm_flags.
> -			 */
> -			if (downgrade &&
> -			    (tmp->vm_flags & VM_PFNMAP))
> -				downgrade = false;
> -
>  			tmp = tmp->vm_next;
>  		}
>  	}
>
diff mbox series

Patch

diff --git a/mm/mmap.c b/mm/mmap.c
index 490340e..847a17d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2771,15 +2771,6 @@  static int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
 				munlock_vma_pages_all(tmp);
 			}
 
-			/*
-			 * Unmapping vmas, which have VM_HUGETLB or VM_PFNMAP,
-			 * need get done with write mmap_sem held since they may
-			 * update vm_flags.
-			 */
-			if (downgrade &&
-			    (tmp->vm_flags & VM_PFNMAP))
-				downgrade = false;
-
 			tmp = tmp->vm_next;
 		}
 	}