diff mbox series

[2/2] hugetlb: update vma flag check for hugetlb vma lock

Message ID 20221212235042.178355-2-mike.kravetz@oracle.com (mailing list archive)
State New
Headers show
Series [1/2] hugetlb: really allocate vma lock for all sharable vmas | expand

Commit Message

Mike Kravetz Dec. 12, 2022, 11:50 p.m. UTC
The check for whether a hugetlb vma lock exists partially depends on
the vma's flags.  Currently, it checks for either VM_MAYSHARE or
VM_SHARED.  The reason both flags are used is because VM_MAYSHARE was
previously cleared in hugetlb vmas as they are tore down.  This is no
longer the case, and only the VM_MAYSHARE check is required.

Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 mm/hugetlb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Miaohe Lin Dec. 17, 2022, 2:01 a.m. UTC | #1
On 2022/12/13 7:50, Mike Kravetz wrote:
> The check for whether a hugetlb vma lock exists partially depends on
> the vma's flags.  Currently, it checks for either VM_MAYSHARE or
> VM_SHARED.  The reason both flags are used is because VM_MAYSHARE was
> previously cleared in hugetlb vmas as they are tore down.  This is no
> longer the case, and only the VM_MAYSHARE check is required.
> 
> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>

Nice cleanup. This is also what I planed to do. ;)

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks,
Miaohe Lin
diff mbox series

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9c251faeb6f5..985881f9e8cc 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -260,8 +260,7 @@  static inline struct hugepage_subpool *subpool_vma(struct vm_area_struct *vma)
  */
 static bool __vma_shareable_lock(struct vm_area_struct *vma)
 {
-	return vma->vm_flags & (VM_MAYSHARE | VM_SHARED) &&
-		vma->vm_private_data;
+	return vma->vm_flags & VM_MAYSHARE && vma->vm_private_data;
 }
 
 void hugetlb_vma_lock_read(struct vm_area_struct *vma)