From: Peter Xu <peterx@redhat.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: peterx@redhat.com, Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Nadav Amit <nadav.amit@gmail.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: [PATCH v2 2/3] mm/hugetlb: Use hugetlb_pte_stable in migration race check
Date: Mon, 3 Oct 2022 20:37:04 -0400 [thread overview]
Message-ID: <20221004003705.497782-3-peterx@redhat.com> (raw)
In-Reply-To: <20221004003705.497782-1-peterx@redhat.com>
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));
--
2.37.3
next prev parent reply other threads:[~2022-10-04 0:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 0:37 [PATCH v2 0/3] mm/hugetlb: Fix selftest failures with write check Peter Xu
2022-10-04 0:37 ` [PATCH v2 1/3] mm/hugetlb: Fix race condition of uffd missing/minor handling Peter Xu
2022-10-04 2:32 ` Mike Kravetz
2022-10-04 13:53 ` Peter Xu
2022-10-04 12:19 ` David Hildenbrand
2022-10-04 13:49 ` Peter Xu
2022-10-04 0:37 ` Peter Xu [this message]
2022-10-04 2:35 ` [PATCH v2 2/3] mm/hugetlb: Use hugetlb_pte_stable in migration race check Mike Kravetz
2022-10-04 12:20 ` David Hildenbrand
2022-10-04 0:37 ` [PATCH v2 3/3] mm/selftest: uffd: Explain the write missing fault check Peter Xu
2022-10-04 2:37 ` Mike Kravetz
2022-10-04 12:20 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221004003705.497782-3-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=nadav.amit@gmail.com \
--cc=rppt@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).