Skip to content

Commit 8809aa2

Browse files
kvaneeshtorvalds
authored andcommitted
mm: clarify that the function operates on hugepage pte
We have confusing functions to clear pmd, pmd_clear_* and pmd_clear. Add _huge_ to pmdp_clear functions so that we are clear that they operate on hugepage pte. We don't bother about other functions like pmdp_set_wrprotect, pmdp_clear_flush_young, because they operate on PTE bits and hence indicate they are operating on hugepage ptes Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f28b6ff commit 8809aa2

13 files changed

Lines changed: 65 additions & 61 deletions

File tree

‎arch/mips/include/asm/pgtable.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,12 @@ static inline pmd_t pmd_mknotpresent(pmd_t pmd)
568568
}
569569

570570
/*
571-
* The generic version pmdp_get_and_clear uses a version of pmd_clear() with a
571+
* The generic version pmdp_huge_get_and_clear uses a version of pmd_clear() with a
572572
* different prototype.
573573
*/
574-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
575-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
576-
unsigned long address, pmd_t *pmdp)
574+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
575+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
576+
unsigned long address, pmd_t *pmdp)
577577
{
578578
pmd_t old = *pmdp;
579579

‎arch/powerpc/include/asm/pgtable-ppc64.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,9 @@ extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
569569
extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
570570
unsigned long address, pmd_t *pmdp);
571571

572-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
573-
extern pmd_t pmdp_get_and_clear(struct mm_struct *mm,
574-
unsigned long addr, pmd_t *pmdp);
572+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
573+
extern pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
574+
unsigned long addr, pmd_t *pmdp);
575575

576576
#define __HAVE_ARCH_PMDP_SET_WRPROTECT
577577
static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,

‎arch/powerpc/mm/pgtable_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,8 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
812812
return;
813813
}
814814

815-
pmd_t pmdp_get_and_clear(struct mm_struct *mm,
816-
unsigned long addr, pmd_t *pmdp)
815+
pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
816+
unsigned long addr, pmd_t *pmdp)
817817
{
818818
pmd_t old_pmd;
819819
pgtable_t pgtable;

‎arch/s390/include/asm/pgtable.h‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,9 +1498,9 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
14981498
return pmd_young(pmd);
14991499
}
15001500

1501-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
1502-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
1503-
unsigned long address, pmd_t *pmdp)
1501+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
1502+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
1503+
unsigned long address, pmd_t *pmdp)
15041504
{
15051505
pmd_t pmd = *pmdp;
15061506

@@ -1509,10 +1509,10 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
15091509
return pmd;
15101510
}
15111511

1512-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR_FULL
1513-
static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
1514-
unsigned long address,
1515-
pmd_t *pmdp, int full)
1512+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR_FULL
1513+
static inline pmd_t pmdp_huge_get_and_clear_full(struct mm_struct *mm,
1514+
unsigned long address,
1515+
pmd_t *pmdp, int full)
15161516
{
15171517
pmd_t pmd = *pmdp;
15181518

@@ -1522,11 +1522,11 @@ static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
15221522
return pmd;
15231523
}
15241524

1525-
#define __HAVE_ARCH_PMDP_CLEAR_FLUSH
1526-
static inline pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
1527-
unsigned long address, pmd_t *pmdp)
1525+
#define __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH
1526+
static inline pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma,
1527+
unsigned long address, pmd_t *pmdp)
15281528
{
1529-
return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
1529+
return pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
15301530
}
15311531

15321532
#define __HAVE_ARCH_PMDP_INVALIDATE
@@ -1552,7 +1552,7 @@ static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,
15521552
unsigned long address,
15531553
pmd_t *pmdp)
15541554
{
1555-
return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
1555+
return pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
15561556
}
15571557
#define pmdp_collapse_flush pmdp_collapse_flush
15581558

‎arch/sparc/include/asm/pgtable_64.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,10 @@ static inline unsigned long pud_pfn(pud_t pud)
865865
void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr,
866866
pte_t *ptep, pte_t orig, int fullmm);
867867

868-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
869-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
870-
unsigned long addr,
871-
pmd_t *pmdp)
868+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
869+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
870+
unsigned long addr,
871+
pmd_t *pmdp)
872872
{
873873
pmd_t pmd = *pmdp;
874874
set_pmd_at(mm, addr, pmdp, __pmd(0UL));

‎arch/tile/include/asm/pgtable.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
414414
}
415415

416416

417-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
418-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
419-
unsigned long address,
420-
pmd_t *pmdp)
417+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
418+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
419+
unsigned long address,
420+
pmd_t *pmdp)
421421
{
422422
return pte_pmd(ptep_get_and_clear(mm, address, pmdp_ptep(pmdp)));
423423
}

‎arch/x86/include/asm/pgtable.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ static inline int pmd_write(pmd_t pmd)
805805
return pmd_flags(pmd) & _PAGE_RW;
806806
}
807807

808-
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
809-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, unsigned long addr,
808+
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
809+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr,
810810
pmd_t *pmdp)
811811
{
812812
pmd_t pmd = native_pmdp_get_and_clear(pmdp);

‎include/asm-generic/pgtable.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
9696
}
9797
#endif
9898

99-
#ifndef __HAVE_ARCH_PMDP_GET_AND_CLEAR
99+
#ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
100100
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
101-
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
102-
unsigned long address,
103-
pmd_t *pmdp)
101+
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
102+
unsigned long address,
103+
pmd_t *pmdp)
104104
{
105105
pmd_t pmd = *pmdp;
106106
pmd_clear(pmdp);
@@ -109,13 +109,13 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
109109
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
110110
#endif
111111

112-
#ifndef __HAVE_ARCH_PMDP_GET_AND_CLEAR_FULL
112+
#ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR_FULL
113113
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
114-
static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
114+
static inline pmd_t pmdp_huge_get_and_clear_full(struct mm_struct *mm,
115115
unsigned long address, pmd_t *pmdp,
116116
int full)
117117
{
118-
return pmdp_get_and_clear(mm, address, pmdp);
118+
return pmdp_huge_get_and_clear(mm, address, pmdp);
119119
}
120120
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
121121
#endif
@@ -152,8 +152,8 @@ extern pte_t ptep_clear_flush(struct vm_area_struct *vma,
152152
pte_t *ptep);
153153
#endif
154154

155-
#ifndef __HAVE_ARCH_PMDP_CLEAR_FLUSH
156-
extern pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
155+
#ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH
156+
extern pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma,
157157
unsigned long address,
158158
pmd_t *pmdp);
159159
#endif

‎include/linux/mmu_notifier.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,25 +324,25 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
324324
___pte; \
325325
})
326326

327-
#define pmdp_clear_flush_notify(__vma, __haddr, __pmd) \
327+
#define pmdp_huge_clear_flush_notify(__vma, __haddr, __pmd) \
328328
({ \
329329
unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \
330330
struct mm_struct *___mm = (__vma)->vm_mm; \
331331
pmd_t ___pmd; \
332332
\
333-
___pmd = pmdp_clear_flush(__vma, __haddr, __pmd); \
333+
___pmd = pmdp_huge_clear_flush(__vma, __haddr, __pmd); \
334334
mmu_notifier_invalidate_range(___mm, ___haddr, \
335335
___haddr + HPAGE_PMD_SIZE); \
336336
\
337337
___pmd; \
338338
})
339339

340-
#define pmdp_get_and_clear_notify(__mm, __haddr, __pmd) \
340+
#define pmdp_huge_get_and_clear_notify(__mm, __haddr, __pmd) \
341341
({ \
342342
unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \
343343
pmd_t ___pmd; \
344344
\
345-
___pmd = pmdp_get_and_clear(__mm, __haddr, __pmd); \
345+
___pmd = pmdp_huge_get_and_clear(__mm, __haddr, __pmd); \
346346
mmu_notifier_invalidate_range(__mm, ___haddr, \
347347
___haddr + HPAGE_PMD_SIZE); \
348348
\
@@ -428,8 +428,8 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
428428
#define ptep_clear_flush_young_notify ptep_clear_flush_young
429429
#define pmdp_clear_flush_young_notify pmdp_clear_flush_young
430430
#define ptep_clear_flush_notify ptep_clear_flush
431-
#define pmdp_clear_flush_notify pmdp_clear_flush
432-
#define pmdp_get_and_clear_notify pmdp_get_and_clear
431+
#define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush
432+
#define pmdp_huge_get_and_clear_notify pmdp_huge_get_and_clear
433433
#define set_pte_at_notify set_pte_at
434434

435435
#endif /* CONFIG_MMU_NOTIFIER */

‎mm/huge_memory.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm,
10311031
goto out_free_pages;
10321032
VM_BUG_ON_PAGE(!PageHead(page), page);
10331033

1034-
pmdp_clear_flush_notify(vma, haddr, pmd);
1034+
pmdp_huge_clear_flush_notify(vma, haddr, pmd);
10351035
/* leave pmd empty until pte is filled */
10361036

10371037
pgtable = pgtable_trans_huge_withdraw(mm, pmd);
@@ -1174,7 +1174,7 @@ int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
11741174
pmd_t entry;
11751175
entry = mk_huge_pmd(new_page, vma->vm_page_prot);
11761176
entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
1177-
pmdp_clear_flush_notify(vma, haddr, pmd);
1177+
pmdp_huge_clear_flush_notify(vma, haddr, pmd);
11781178
page_add_new_anon_rmap(new_page, vma, haddr);
11791179
mem_cgroup_commit_charge(new_page, memcg, false);
11801180
lru_cache_add_active_or_unevictable(new_page, vma);
@@ -1396,12 +1396,12 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
13961396
pmd_t orig_pmd;
13971397
/*
13981398
* For architectures like ppc64 we look at deposited pgtable
1399-
* when calling pmdp_get_and_clear. So do the
1399+
* when calling pmdp_huge_get_and_clear. So do the
14001400
* pgtable_trans_huge_withdraw after finishing pmdp related
14011401
* operations.
14021402
*/
1403-
orig_pmd = pmdp_get_and_clear_full(tlb->mm, addr, pmd,
1404-
tlb->fullmm);
1403+
orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd,
1404+
tlb->fullmm);
14051405
tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
14061406
pgtable = pgtable_trans_huge_withdraw(tlb->mm, pmd);
14071407
if (is_huge_zero_pmd(orig_pmd)) {
@@ -1459,7 +1459,7 @@ int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
14591459
new_ptl = pmd_lockptr(mm, new_pmd);
14601460
if (new_ptl != old_ptl)
14611461
spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
1462-
pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
1462+
pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
14631463
VM_BUG_ON(!pmd_none(*new_pmd));
14641464

14651465
if (pmd_move_must_withdraw(new_ptl, old_ptl)) {
@@ -1505,7 +1505,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
15051505
}
15061506

15071507
if (!prot_numa || !pmd_protnone(*pmd)) {
1508-
entry = pmdp_get_and_clear_notify(mm, addr, pmd);
1508+
entry = pmdp_huge_get_and_clear_notify(mm, addr, pmd);
15091509
entry = pmd_modify(entry, newprot);
15101510
if (preserve_write)
15111511
entry = pmd_mkwrite(entry);
@@ -2863,7 +2863,7 @@ static void __split_huge_zero_page_pmd(struct vm_area_struct *vma,
28632863
pmd_t _pmd;
28642864
int i;
28652865

2866-
pmdp_clear_flush_notify(vma, haddr, pmd);
2866+
pmdp_huge_clear_flush_notify(vma, haddr, pmd);
28672867
/* leave pmd empty until pte is filled */
28682868

28692869
pgtable = pgtable_trans_huge_withdraw(mm, pmd);

0 commit comments

Comments
 (0)