Skip to contentSkip to conversation

mm-provide-mm_struct-and-address-to-huge_ptep_get.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jul 12, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: provide mm_struct and address to huge_ptep_get()
has been removed from the -mm tree. Its filename was
mm-provide-mm_struct-and-address-to-huge_ptep_get.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: Christophe Leroy <[email protected]>
Subject: mm: provide mm_struct and address to huge_ptep_get()
Date: Tue, 2 Jul 2024 15:51:20 +0200

On powerpc 8xx huge_ptep_get() will need to know whether the given ptep is a PTE entry or a PMD entry. This cannot be known with the PMD entry itself because there is no easy way to know it from the content of the entry.

So huge_ptep_get() will need to know either the size of the page or get the pmd.

In order to be consistent with huge_ptep_get_and_clear(), give mm and address to huge_ptep_get().

---

 arch/arm/include/asm/hugetlb-3level.h |    4 +-
 arch/arm64/include/asm/hugetlb.h      |    2 -
 arch/arm64/mm/hugetlbpage.c           |    2 -
 arch/riscv/include/asm/hugetlb.h      |    2 -
 arch/riscv/mm/hugetlbpage.c           |    2 -
 arch/s390/include/asm/hugetlb.h       |    4 +-
 arch/s390/mm/hugetlbpage.c            |    4 +-
 fs/hugetlbfs/inode.c                  |    2 -
 fs/proc/task_mmu.c                    |   10 ++---
 fs/userfaultfd.c                      |    2 -
 include/asm-generic/hugetlb.h         |    2 -
 include/linux/swapops.h               |    4 +-
 mm/damon/vaddr.c                      |    6 +--
 mm/gup.c                              |    2 -
 mm/hmm.c                              |    2 -
 mm/hugetlb.c                          |   44 ++++++++++++------------
 mm/memory-failure.c                   |    2 -
 mm/mempolicy.c                        |    2 -
 mm/migrate.c                          |    4 +-
 mm/mincore.c                          |    2 -
 mm/userfaultfd.c                      |    2 -
 21 files changed, 53 insertions(+), 53 deletions(-)
arch/arm64/include/asm/hugetlb.h renamed from arch/arm64/include/asm/hugetlb.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -46,7 +46,7 @@ extern pte_t huge_ptep_clear_flush(struc
 extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
 			   pte_t *ptep, unsigned long sz);
 #define __HAVE_ARCH_HUGE_PTEP_GET
-extern pte_t huge_ptep_get(pte_t *ptep);
+extern pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 
 void __init arm64_hugetlb_cma_reserve(void);
 
arch/arm64/mm/hugetlbpage.c renamed from arch/arm64/mm/hugetlbpage.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -127,7 +127,7 @@ static inline int num_contig_ptes(unsign
 	return contig_ptes;
 }
 
-pte_t huge_ptep_get(pte_t *ptep)
+pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	int ncontig, i;
 	size_t pgsize;
arch/arm/include/asm/hugetlb-3level.h renamed from arch/arm/include/asm/hugetlb-3level.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +2 -2
@@ -13,12 +13,12 @@
 
 /*
  * If our huge pte is non-zero then mark the valid bit.
- * This allows pte_present(huge_ptep_get(ptep)) to return true for non-zero
+ * This allows pte_present(huge_ptep_get(mm,addr,ptep)) to return true for non-zero
  * ptes.
  * (The valid bit is automatically cleared by set_pte_at for PROT_NONE ptes).
  */
 #define __HAVE_ARCH_HUGE_PTEP_GET
-static inline pte_t huge_ptep_get(pte_t *ptep)
+static inline pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t retval = *ptep;
 	if (pte_val(retval))
arch/riscv/include/asm/hugetlb.h renamed from arch/riscv/include/asm/hugetlb.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -44,7 +44,7 @@ int huge_ptep_set_access_flags(struct vm
 			       pte_t pte, int dirty);
 
 #define __HAVE_ARCH_HUGE_PTEP_GET
-pte_t huge_ptep_get(pte_t *ptep);
+pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 
 pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags);
 #define arch_make_huge_pte arch_make_huge_pte
arch/riscv/mm/hugetlbpage.c renamed from arch/riscv/mm/hugetlbpage.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -3,7 +3,7 @@
 #include <linux/err.h>
 
 #ifdef CONFIG_RISCV_ISA_SVNAPOT
-pte_t huge_ptep_get(pte_t *ptep)
+pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	unsigned long pte_num;
 	int i;
arch/s390/include/asm/hugetlb.h renamed from arch/s390/include/asm/hugetlb.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +2 -2
@@ -19,7 +19,7 @@ void set_huge_pte_at(struct mm_struct *m
 		     pte_t *ptep, pte_t pte, unsigned long sz);
 void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 		     pte_t *ptep, pte_t pte);
-pte_t huge_ptep_get(pte_t *ptep);
+pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 			      unsigned long addr, pte_t *ptep);
 
@@ -64,7 +64,7 @@ static inline int huge_ptep_set_access_f
 					     unsigned long addr, pte_t *ptep,
 					     pte_t pte, int dirty)
 {
-	int changed = !pte_same(huge_ptep_get(ptep), pte);
+	int changed = !pte_same(huge_ptep_get(vma->vm_mm, addr, ptep), pte);
 	if (changed) {
 		huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
 		__set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
arch/s390/mm/hugetlbpage.c renamed from arch/s390/mm/hugetlbpage.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +2 -2
@@ -169,7 +169,7 @@ void set_huge_pte_at(struct mm_struct *m
 	__set_huge_pte_at(mm, addr, ptep, pte);
 }
 
-pte_t huge_ptep_get(pte_t *ptep)
+pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	return __rste_to_pte(pte_val(*ptep));
 }
@@ -177,7 +177,7 @@ pte_t huge_ptep_get(pte_t *ptep)
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 			      unsigned long addr, pte_t *ptep)
 {
-	pte_t pte = huge_ptep_get(ptep);
+	pte_t pte = huge_ptep_get(mm, addr, ptep);
 	pmd_t *pmdp = (pmd_t *) ptep;
 	pud_t *pudp = (pud_t *) ptep;
 
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -422,7 +422,7 @@ static bool hugetlb_vma_maps_page(struct
 	if (!ptep)
 		return false;
 
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(vma->vm_mm, addr, ptep);
 	if (huge_pte_none(pte) || !pte_present(pte))
 		return false;
 
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +5 -5
@@ -1013,7 +1013,7 @@ static int smaps_hugetlb_range(pte_t *pt
 {
 	struct mem_size_stats *mss = walk->private;
 	struct vm_area_struct *vma = walk->vma;
-	pte_t ptent = huge_ptep_get(pte);
+	pte_t ptent = huge_ptep_get(walk->mm, addr, pte);
 	struct folio *folio = NULL;
 	bool present = false;
 
@@ -1878,7 +1878,7 @@ static int pagemap_hugetlb_range(pte_t *
 	if (vma->vm_flags & VM_SOFTDIRTY)
 		flags |= PM_SOFT_DIRTY;
 
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(walk->mm, addr, ptep);
 	if (pte_present(pte)) {
 		struct folio *folio = page_folio(pte_page(pte));
 
@@ -2567,7 +2567,7 @@ static int pagemap_scan_hugetlb_entry(pt
 	if (~p->arg.flags & PM_SCAN_WP_MATCHING) {
 		/* Go the short route when not write-protecting pages. */
 
-		pte = huge_ptep_get(ptep);
+		pte = huge_ptep_get(walk->mm, start, ptep);
 		categories = p->cur_vma_category | pagemap_hugetlb_category(pte);
 
 		if (!pagemap_scan_is_interesting_page(categories, p))
@@ -2579,7 +2579,7 @@ static int pagemap_scan_hugetlb_entry(pt
 	i_mmap_lock_write(vma->vm_file->f_mapping);
 	ptl = huge_pte_lock(hstate_vma(vma), vma->vm_mm, ptep);
 
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(walk->mm, start, ptep);
 	categories = p->cur_vma_category | pagemap_hugetlb_category(pte);
 
 	if (!pagemap_scan_is_interesting_page(categories, p))
@@ -2975,7 +2975,7 @@ static int gather_pte_stats(pmd_t *pmd,
 static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask,
 		unsigned long addr, unsigned long end, struct mm_walk *walk)
 {
-	pte_t huge_pte = huge_ptep_get(pte);
+	pte_t huge_pte = huge_ptep_get(walk->mm, addr, pte);
 	struct numa_maps *md;
 	struct page *page;
 
fs/userfaultfd.c renamed from fs/userfaultfd.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -257,7 +257,7 @@ static inline bool userfaultfd_huge_must
 		goto out;
 
 	ret = false;
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(vma->vm_mm, vmf->address, ptep);
 
 	/*
 	 * Lockless access: we're in a wait_event so it's ok if it
include/asm-generic/hugetlb.h renamed from include/asm-generic/hugetlb.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -144,7 +144,7 @@ static inline int huge_ptep_set_access_f
 #endif
 
 #ifndef __HAVE_ARCH_HUGE_PTEP_GET
-static inline pte_t huge_ptep_get(pte_t *ptep)
+static inline pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	return ptep_get(ptep);
 }
include/linux/swapops.h renamed from include/linux/swapops.h~mm-provide-mm_struct-and-address-to-huge_ptep_get +2 -2
@@ -334,7 +334,7 @@ static inline bool is_migration_entry_di
 
 extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
 					unsigned long address);
-extern void migration_entry_wait_huge(struct vm_area_struct *vma, pte_t *pte);
+extern void migration_entry_wait_huge(struct vm_area_struct *vma, unsigned long addr, pte_t *pte);
 #else  /* CONFIG_MIGRATION */
 static inline swp_entry_t make_readable_migration_entry(pgoff_t offset)
 {
@@ -359,7 +359,7 @@ static inline int is_migration_entry(swp
 static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
 					unsigned long address) { }
 static inline void migration_entry_wait_huge(struct vm_area_struct *vma,
-					pte_t *pte) { }
+					     unsigned long addr, pte_t *pte) { }
 static inline int is_writable_migration_entry(swp_entry_t entry)
 {
 	return 0;
mm/damon/vaddr.c renamed from mm/damon/vaddr.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +3 -3
@@ -339,7 +339,7 @@ static void damon_hugetlb_mkold(pte_t *p
 				struct vm_area_struct *vma, unsigned long addr)
 {
 	bool referenced = false;
-	pte_t entry = huge_ptep_get(pte);
+	pte_t entry = huge_ptep_get(mm, addr, pte);
 	struct folio *folio = pfn_folio(pte_pfn(entry));
 	unsigned long psize = huge_page_size(hstate_vma(vma));
 
@@ -373,7 +373,7 @@ static int damon_mkold_hugetlb_entry(pte
 	pte_t entry;
 
 	ptl = huge_pte_lock(h, walk->mm, pte);
-	entry = huge_ptep_get(pte);
+	entry = huge_ptep_get(walk->mm, addr, pte);
 	if (!pte_present(entry))
 		goto out;
 
@@ -509,7 +509,7 @@ static int damon_young_hugetlb_entry(pte
 	pte_t entry;
 
 	ptl = huge_pte_lock(h, walk->mm, pte);
-	entry = huge_ptep_get(pte);
+	entry = huge_ptep_get(walk->mm, addr, pte);
 	if (!pte_present(entry))
 		goto out;
 
mm/gup.c renamed from mm/gup.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -604,7 +604,7 @@ static int gup_hugepte(struct vm_area_st
 	if (pte_end < end)
 		end = pte_end;
 
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(vma->vm_mm, addr, ptep);
 
 	if (!pte_access_permitted(pte, flags & FOLL_WRITE))
 		return 0;
mm/hmm.c renamed from mm/hmm.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -480,7 +480,7 @@ static int hmm_vma_walk_hugetlb_entry(pt
 	pte_t entry;
 
 	ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte);
-	entry = huge_ptep_get(pte);
+	entry = huge_ptep_get(walk->mm, addr, pte);
 
 	i = (start - range->start) >> PAGE_SHIFT;
 	pfn_req_flags = range->hmm_pfns[i];
mm/hugetlb.c renamed from mm/hugetlb.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +22 -22

173 lines not on this page · raw message

mm/memory-failure.c renamed from mm/memory-failure.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -835,7 +835,7 @@ static int hwpoison_hugetlb_range(pte_t
 			    struct mm_walk *walk)
 {
 	struct hwpoison_walk *hwp = walk->private;
-	pte_t pte = huge_ptep_get(ptep);
+	pte_t pte = huge_ptep_get(walk->mm, addr, ptep);
 	struct hstate *h = hstate_vma(walk->vma);
 
 	return check_hwpoisoned_entry(pte, addr, huge_page_shift(h),
mm/mempolicy.c renamed from mm/mempolicy.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -624,7 +624,7 @@ static int queue_folios_hugetlb(pte_t *p
 	pte_t entry;
 
 	ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
-	entry = huge_ptep_get(pte);
+	entry = huge_ptep_get(walk->mm, addr, pte);
 	if (!pte_present(entry)) {
 		if (unlikely(is_hugetlb_entry_migration(entry)))
 			qp->nr_failed++;
mm/migrate.c renamed from mm/migrate.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +2 -2
@@ -338,14 +338,14 @@ out:
  *
  * This function will release the vma lock before returning.
  */
-void migration_entry_wait_huge(struct vm_area_struct *vma, pte_t *ptep)
+void migration_entry_wait_huge(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	spinlock_t *ptl = huge_pte_lockptr(hstate_vma(vma), vma->vm_mm, ptep);
 	pte_t pte;
 
 	hugetlb_vma_assert_locked(vma);
 	spin_lock(ptl);
-	pte = huge_ptep_get(ptep);
+	pte = huge_ptep_get(vma->vm_mm, addr, ptep);
 
 	if (unlikely(!is_hugetlb_entry_migration(pte))) {
 		spin_unlock(ptl);
mm/mincore.c renamed from mm/mincore.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -33,7 +33,7 @@ static int mincore_hugetlb(pte_t *pte, u
 	 * Hugepages under user process are always in RAM and never
 	 * swapped out, but theoretically it needs to be checked.
 	 */
-	present = pte && !huge_pte_none_mostly(huge_ptep_get(pte));
+	present = pte && !huge_pte_none_mostly(huge_ptep_get(walk->mm, addr, pte));
 	for (; addr != end; vec++, addr += PAGE_SIZE)
 		*vec = present;
 	walk->private = vec;
mm/userfaultfd.c renamed from mm/userfaultfd.c~mm-provide-mm_struct-and-address-to-huge_ptep_get +1 -1
@@ -587,7 +587,7 @@ retry:
 		}
 
 		if (!uffd_flags_mode_is(flags, MFILL_ATOMIC_CONTINUE) &&
-		    !huge_pte_none_mostly(huge_ptep_get(dst_pte))) {
+		    !huge_pte_none_mostly(huge_ptep_get(dst_mm, dst_addr, dst_pte))) {
 			err = -EEXIST;
 			hugetlb_vma_unlock_read(dst_vma);
 			mutex_unlock(&hugetlb_fault_mutex_table[hash]);

_

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