diff mbox series

[v2,2/3] mm/hugetlb: Use hugetlb_pte_stable in migration race check

Message ID 20221004003705.497782-3-peterx@redhat.com (mailing list archive)
State New
Headers show
Series mm/hugetlb: Fix selftest failures with write check | expand

Commit Message

Peter Xu Oct. 4, 2022, 12:37 a.m. UTC
After hugetlb_pte_stable() introduced, we can also rewrite the migration
race condition against page allocation to use the new helper too.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 mm/hugetlb.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Mike Kravetz Oct. 4, 2022, 2:35 a.m. UTC | #1
On 10/03/22 20:37, Peter Xu wrote:
> After hugetlb_pte_stable() introduced, we can also rewrite the migration
> race condition against page allocation to use the new helper too.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  mm/hugetlb.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
David Hildenbrand Oct. 4, 2022, 12:20 p.m. UTC | #2
On 04.10.22 02:37, Peter Xu wrote:
> After hugetlb_pte_stable() introduced, we can also rewrite the migration
> race condition against page allocation to use the new helper too.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>   mm/hugetlb.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index fa3fcdb0c4b8..e762c5369a6f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5620,11 +5620,10 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
>   			 * here.  Before returning error, get ptl and make
>   			 * sure there really is no pte entry.
>   			 */
> -			ptl = huge_pte_lock(h, mm, ptep);
> -			ret = 0;
> -			if (huge_pte_none(huge_ptep_get(ptep)))
> +			if (hugetlb_pte_stable(h, mm, ptep, old_pte))
>   				ret = vmf_error(PTR_ERR(page));
> -			spin_unlock(ptl);
> +			else
> +				ret = 0;
>   			goto out;
>   		}
>   		clear_huge_page(page, address, pages_per_huge_page(h));

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

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index fa3fcdb0c4b8..e762c5369a6f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5620,11 +5620,10 @@  static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
 			 * here.  Before returning error, get ptl and make
 			 * sure there really is no pte entry.
 			 */
-			ptl = huge_pte_lock(h, mm, ptep);
-			ret = 0;
-			if (huge_pte_none(huge_ptep_get(ptep)))
+			if (hugetlb_pte_stable(h, mm, ptep, old_pte))
 				ret = vmf_error(PTR_ERR(page));
-			spin_unlock(ptl);
+			else
+				ret = 0;
 			goto out;
 		}
 		clear_huge_page(page, address, pages_per_huge_page(h));