Skip to contentSkip to conversation

mm-gup-handle-huge-pud-for-follow_pud_mask.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Apr 26, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/gup: handle huge pud for follow_pud_mask()
has been removed from the -mm tree. Its filename was
mm-gup-handle-huge-pud-for-follow_pud_mask.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Peter Xu <[email protected]>
Subject: mm/gup: handle huge pud for follow_pud_mask()
Date: Wed, 27 Mar 2024 11:23:29 -0400

Teach follow_pud_mask() to be able to handle normal PUD pages like hugetlb.

Rename follow_devmap_pud() to follow_huge_pud() so that it can process either huge devmap or hugetlb. Move it out of TRANSPARENT_HUGEPAGE_PUD and and huge_memory.c (which relies on CONFIG_THP). Switch to pud_leaf() to detect both cases in the slow gup.

In the new follow_huge_pud(), taking care of possible CoR for hugetlb if necessary. touch_pud() needs to be moved out of huge_memory.c to be accessable from gup.c even if !THP.

Since at it, optimize the non-present check by adding a pud_present() early check before taking the pgtable lock, failing the follow_page() early if PUD is not present: that is required by both devmap or hugetlb. Use pud_huge() to also cover the pud_devmap() case.

One more trivial thing to mention is, introduce "pud_t pud" in the code paths along the way, so the code doesn't dereference *pudp multiple time. Not only because that looks less straightforward, but also because if the dereference really happened, it's not clear whether there can be race to see different *pudp values when it's being modified at the same time.

Setting ctx->page_mask properly for a PUD entry. As a side effect, this patch should also be able to optimize devmap GUP on PUD to be able to jump over the whole PUD range, but not yet verified. Hugetlb already can do so prior to this patch.

Cc Andrea Arcangeli <[email protected]>
Cc Andrew Jones <[email protected]>
Cc Aneesh Kumar K.V (IBM) <[email protected]>
Cc Axel Rasmussen <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc James Houghton <[email protected]>
Cc John Hubbard <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc "Mike Rapoport (IBM)" <[email protected]>
Cc Muchun Song <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>

---

 include/linux/huge_mm.h |    8 ----
 mm/gup.c                |   70 ++++++++++++++++++++++++++++++++++++--
 mm/huge_memory.c        |   47 +------------------------
 mm/internal.h           |    2 +
 4 files changed, 71 insertions(+), 56 deletions(-)
include/linux/huge_mm.h renamed from include/linux/huge_mm.h~mm-gup-handle-huge-pud-for-follow_pud_mask +0 -8
@@ -351,8 +351,6 @@ static inline bool folio_test_pmd_mappab
 
 struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
 		pmd_t *pmd, int flags, struct dev_pagemap **pgmap);
-struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr,
-		pud_t *pud, int flags, struct dev_pagemap **pgmap);
 
 vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf);
 
@@ -506,12 +504,6 @@ static inline struct page *follow_devmap
 {
 	return NULL;
 }
-
-static inline struct page *follow_devmap_pud(struct vm_area_struct *vma,
-	unsigned long addr, pud_t *pud, int flags, struct dev_pagemap **pgmap)
-{
-	return NULL;
-}
 
 static inline bool thp_migration_supported(void)
 {
mm/gup.c renamed from mm/gup.c~mm-gup-handle-huge-pud-for-follow_pud_mask +67 -3

84 lines not on this page · raw message

mm/huge_memory.c renamed from mm/huge_memory.c~mm-gup-handle-huge-pud-for-follow_pud_mask +2 -45

59 lines not on this page · raw message

mm/internal.h renamed from mm/internal.h~mm-gup-handle-huge-pud-for-follow_pud_mask +2 -0
@@ -1112,6 +1112,8 @@ int __must_check try_grab_page(struct pa
 /*
  * mm/huge_memory.c
  */
+void touch_pud(struct vm_area_struct *vma, unsigned long addr,
+	       pud_t *pud, bool write);
 struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
 				   unsigned long addr, pmd_t *pmd,
 				   unsigned int flags);

_

Patches currently in -mm which might be from [email protected] are

mm-userfaultfd-reset-ptes-when-close-for-wr-protected-ones.patch mm-hugetlb-assert-hugetlb_lock-in-__hugetlb_cgroup_commit_charge.patch mm-page_table_check-support-userfault-wr-protect-entries.patch