Skip to contentSkip to conversation

simplify follow_pte a bit

PATCH In review Christoph Hellwig 5 participants 11 messages Oct 29, 2020 – Nov 11, 2020

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

Hi Andrew,

this small series drops the not needed follow_pte_pmd exports, and simplifies the follow_pte family of functions a bit.

#1 lore raw

PATCH 1/2 mm: unexport follow_pte_pmd

follow_pte_pmd is only used by the DAX code, which can't be modular.

---
 mm/memory.c | 1 -
 1 file changed, 1 deletion(-)
mm/memory.c +0 -1
index c48f8df6e50268..00458e7b49fef8 100644
@@ -4787,7 +4787,6 @@ int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
 						    ptepp, pmdpp, ptlp)));
 	return res;
 }
-EXPORT_SYMBOL(follow_pte_pmd);
 
 /**
  * follow_pfn - look up PFN at a user virtual address
Signature · 4 lines
2.28.0
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#3 lore raw

PATCH 2/2 mm: simplify follow_pte{,pmd}

In reply to Christoph Hellwig

Merge __follow_pte_pmd, follow_pte_pmd and follow_pte into a single follow_pte function and just pass two additional NULL arguments for the two previous follow_pte callers.

---
 fs/dax.c           |  9 ++++-----
 include/linux/mm.h |  6 +++---
 mm/memory.c        | 35 +++++------------------------------
 3 files changed, 12 insertions(+), 38 deletions(-)
fs/dax.c +4 -5
index 5b47834f2e1bb5..26d5dcd2d69e5c 100644
@@ -810,12 +810,11 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index,
 		address = pgoff_address(index, vma);
 
 		/*
-		 * Note because we provide range to follow_pte_pmd it will
-		 * call mmu_notifier_invalidate_range_start() on our behalf
-		 * before taking any lock.
+		 * Note because we provide range to follow_pte it will call
+		 * mmu_notifier_invalidate_range_start() on our behalf before
+		 * taking any lock.
 		 */
-		if (follow_pte_pmd(vma->vm_mm, address, &range,
-				   &ptep, &pmdp, &ptl))
+		if (follow_pte(vma->vm_mm, address, &range, &ptep, &pmdp, &ptl))
 			continue;
 
 		/*
include/linux/mm.h +3 -3
index ef360fe70aafcf..113b0b4fd90af5 100644
@@ -1655,9 +1655,9 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
 		unsigned long end, unsigned long floor, unsigned long ceiling);
 int
 copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma);
-int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
-		   struct mmu_notifier_range *range,
-		   pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
+int follow_pte(struct mm_struct *mm, unsigned long address,
+		struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp,
+		spinlock_t **ptlp);
 int follow_pfn(struct vm_area_struct *vma, unsigned long address,
 	unsigned long *pfn);
 int follow_phys(struct vm_area_struct *vma, unsigned long address,
mm/memory.c +5 -30
index 00458e7b49fef8..fa00682f7a4312 100644
@@ -4696,9 +4696,9 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
 }
 #endif /* __PAGETABLE_PMD_FOLDED */
 
-static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
-			    struct mmu_notifier_range *range,
-			    pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
+int follow_pte(struct mm_struct *mm, unsigned long address,
+	       struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp,
+	       spinlock_t **ptlp)
 {
 	pgd_t *pgd;
 	p4d_t *p4d;
@@ -4763,31 +4763,6 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
 	return -EINVAL;
 }
 
-static inline int follow_pte(struct mm_struct *mm, unsigned long address,
-			     pte_t **ptepp, spinlock_t **ptlp)
-{
-	int res;
-
-	/* (void) is needed to make gcc happy */
-	(void) __cond_lock(*ptlp,
-			   !(res = __follow_pte_pmd(mm, address, NULL,
-						    ptepp, NULL, ptlp)));
-	return res;
-}
-
-int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
-		   struct mmu_notifier_range *range,
-		   pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
-{
-	int res;
-
-	/* (void) is needed to make gcc happy */
-	(void) __cond_lock(*ptlp,
-			   !(res = __follow_pte_pmd(mm, address, range,
-						    ptepp, pmdpp, ptlp)));
-	return res;
-}
-
 /**
  * follow_pfn - look up PFN at a user virtual address
  * @vma: memory mapping
@@ -4808,7 +4783,7 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
 	if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
 		return ret;
 
-	ret = follow_pte(vma->vm_mm, address, &ptep, &ptl);
+	ret = follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl);
 	if (ret)
 		return ret;
 	*pfn = pte_pfn(*ptep);
@@ -4829,7 +4804,7 @@ int follow_phys(struct vm_area_struct *vma,
 	if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
 		goto out;
 
-	if (follow_pte(vma->vm_mm, address, &ptep, &ptl))
+	if (follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl))
 		goto out;
 	pte = *ptep;
 
Signature · 4 lines
2.28.0
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
reviewer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] mm: simplify follow_pte{,pmd}

Quoted 5 lines · Christoph Hellwig

Merge __follow_pte_pmd, follow_pte_pmd and follow_pte into a single follow_pte function and just pass two additional NULL arguments for the two previous follow_pte callers.

I'm not entirely convinced this is the right interface, but your patch makes things better, so I approve.
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

#7 lore raw

Re: [PATCH 2/2] mm: simplify follow_pte{,pmd}

Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Nick Desaulniers

Sorry, I think this patch may be causing a regression for us for s390?
https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/432129279#L768

(via https://lore.kernel.org/linux-mm/[email protected])

Hmm, the call to follow_pte_pmd in the s390 code does not actually exist in my tree.

This is a mid-air collision in linux-next between

b2ff5796a934 ("mm: simplify follow_pte{,pmd}") a67a88b0b8de ("s390/pci: remove races against pte updates")

#8 lore raw

Re: [PATCH 2/2] mm: simplify follow_pte{,pmd}

Quoted 8 lines · Christian Borntraeger
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Nick Desaulniers

Sorry, I think this patch may be causing a regression for us for s390?
https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/432129279#L768

(via https://lore.kernel.org/linux-mm/[email protected])

Quoted 7 lines
Quoted 2 lines

Hmm, the call to follow_pte_pmd in the s390 code does not actually exist in my tree.

This is a mid-air collision in linux-next between

b2ff5796a934 ("mm: simplify follow_pte{,pmd}") a67a88b0b8de ("s390/pci: remove races against pte updates")

Ah. The fixup is trivial: just s/follow_pte_pmd/follow_pte/.

#9 lore raw

Re: [PATCH 2/2] mm: simplify follow_pte{,pmd}

Hi Christoph,

Quoted 13 lines · On Wed, 11 Nov 2020 09:28:42 +0100 Christoph Hellwig <[email protected]> wrote:
Quoted 11 lines · Christian Borntraeger
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Nick Desaulniers

Sorry, I think this patch may be causing a regression for us for s390?
https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/432129279#L768

(via https://lore.kernel.org/linux-mm/[email protected])

Hmm, the call to follow_pte_pmd in the s390 code does not actually exist in my tree.

Quoted 6 lines
Quoted 4 lines

This is a mid-air collision in linux-next between

b2ff5796a934 ("mm: simplify follow_pte{,pmd}") a67a88b0b8de ("s390/pci: remove races against pte updates")

Ah. The fixup is trivial: just s/follow_pte_pmd/follow_pte/.

ok, so tomorrow I will add the following to the merge of the akpm-current tree:

From: Stephen Rothwell <[email protected]>
Date: Wed, 11 Nov 2020 22:08:32 +1100
Subject: [PATCH] merge fix for "s390/pci: remove races against pte updates"

---
 arch/s390/pci/pci_mmio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/pci/pci_mmio.c +2 -2
index 1a6adbc68ee8..4a4993837413 100644
@@ -173,7 +173,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
 	if (!(vma->vm_flags & VM_WRITE))
 		goto out_unlock_mmap;
 
-	ret = follow_pte_pmd(vma->vm_mm, mmio_addr, NULL, &ptep, NULL, &ptl);
+	ret = follow_pte(vma->vm_mm, mmio_addr, NULL, &ptep, NULL, &ptl);
 	if (ret)
 		goto out_unlock_mmap;
 
@@ -317,7 +317,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
 	if (!(vma->vm_flags & VM_WRITE))
 		goto out_unlock_mmap;
 
-	ret = follow_pte_pmd(vma->vm_mm, mmio_addr, NULL, &ptep, NULL, &ptl);
+	ret = follow_pte(vma->vm_mm, mmio_addr, NULL, &ptep, NULL, &ptl);
 	if (ret)
 		goto out_unlock_mmap;
 
Signature · 5 lines
2.29.2

-- 
Cheers,
Stephen Rothwell