Skip to content

Commit 78c7b24

Browse files
Christoph Hellwiggregkh
authored andcommitted
mm: simplify follow_pte{,pmd}
commit ff5c19e upstream. 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. [sfr@canb.auug.org.au: merge fix for "s390/pci: remove races against pte updates"] Link: https://lkml.kernel.org/r/20201111221254.7f6a3658@canb.auug.org.au Link: https://lkml.kernel.org/r/20201029101432.47011-3-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8aeef9c commit 78c7b24

3 files changed

Lines changed: 12 additions & 38 deletions

File tree

fs/dax.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,11 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index,
794794
address = pgoff_address(index, vma);
795795

796796
/*
797-
* Note because we provide range to follow_pte_pmd it will
798-
* call mmu_notifier_invalidate_range_start() on our behalf
799-
* before taking any lock.
797+
* Note because we provide range to follow_pte it will call
798+
* mmu_notifier_invalidate_range_start() on our behalf before
799+
* taking any lock.
800800
*/
801-
if (follow_pte_pmd(vma->vm_mm, address, &range,
802-
&ptep, &pmdp, &ptl))
801+
if (follow_pte(vma->vm_mm, address, &range, &ptep, &pmdp, &ptl))
803802
continue;
804803

805804
/*

include/linux/mm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,9 +1466,9 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
14661466
unsigned long end, unsigned long floor, unsigned long ceiling);
14671467
int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
14681468
struct vm_area_struct *vma);
1469-
int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
1470-
struct mmu_notifier_range *range,
1471-
pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
1469+
int follow_pte(struct mm_struct *mm, unsigned long address,
1470+
struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp,
1471+
spinlock_t **ptlp);
14721472
int follow_pfn(struct vm_area_struct *vma, unsigned long address,
14731473
unsigned long *pfn);
14741474
int follow_phys(struct vm_area_struct *vma, unsigned long address,

mm/memory.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,9 +4222,9 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
42224222
}
42234223
#endif /* __PAGETABLE_PMD_FOLDED */
42244224

4225-
static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
4226-
struct mmu_notifier_range *range,
4227-
pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
4225+
int follow_pte(struct mm_struct *mm, unsigned long address,
4226+
struct mmu_notifier_range *range, pte_t **ptepp, pmd_t **pmdpp,
4227+
spinlock_t **ptlp)
42284228
{
42294229
pgd_t *pgd;
42304230
p4d_t *p4d;
@@ -4289,31 +4289,6 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
42894289
return -EINVAL;
42904290
}
42914291

4292-
static inline int follow_pte(struct mm_struct *mm, unsigned long address,
4293-
pte_t **ptepp, spinlock_t **ptlp)
4294-
{
4295-
int res;
4296-
4297-
/* (void) is needed to make gcc happy */
4298-
(void) __cond_lock(*ptlp,
4299-
!(res = __follow_pte_pmd(mm, address, NULL,
4300-
ptepp, NULL, ptlp)));
4301-
return res;
4302-
}
4303-
4304-
int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
4305-
struct mmu_notifier_range *range,
4306-
pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
4307-
{
4308-
int res;
4309-
4310-
/* (void) is needed to make gcc happy */
4311-
(void) __cond_lock(*ptlp,
4312-
!(res = __follow_pte_pmd(mm, address, range,
4313-
ptepp, pmdpp, ptlp)));
4314-
return res;
4315-
}
4316-
43174292
/**
43184293
* follow_pfn - look up PFN at a user virtual address
43194294
* @vma: memory mapping
@@ -4334,7 +4309,7 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
43344309
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
43354310
return ret;
43364311

4337-
ret = follow_pte(vma->vm_mm, address, &ptep, &ptl);
4312+
ret = follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl);
43384313
if (ret)
43394314
return ret;
43404315
*pfn = pte_pfn(*ptep);
@@ -4355,7 +4330,7 @@ int follow_phys(struct vm_area_struct *vma,
43554330
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
43564331
goto out;
43574332

4358-
if (follow_pte(vma->vm_mm, address, &ptep, &ptl))
4333+
if (follow_pte(vma->vm_mm, address, NULL, &ptep, NULL, &ptl))
43594334
goto out;
43604335
pte = *ptep;
43614336

0 commit comments

Comments
 (0)