]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: clarify that the function operates on hugepage pte
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Wed, 24 Jun 2015 23:57:44 +0000 (16:57 -0700)
committerDan Duval <dan.duval@oracle.com>
Wed, 7 Dec 2016 17:19:36 +0000 (12:19 -0500)
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>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit 8809aa2d28d74111ff2f1928edaa4e9845c97a7d)

Conflict:

arch/sparc/include/asm/pgtable_64.h

13 files changed:
arch/mips/include/asm/pgtable.h
arch/powerpc/include/asm/pgtable-ppc64.h
arch/powerpc/mm/pgtable_64.c
arch/s390/include/asm/pgtable.h
arch/sparc/include/asm/pgtable_64.h
arch/tile/include/asm/pgtable.h
arch/x86/include/asm/pgtable.h
include/asm-generic/pgtable.h
include/linux/mmu_notifier.h
mm/huge_memory.c
mm/migrate.c
mm/pgtable-generic.c
mm/rmap.c

index 70f6e7f073b047a71c18e5b5dab815bc514d8dd6..ae85694752644339af22557a5ae424cde8271400 100644 (file)
@@ -599,12 +599,12 @@ static inline pmd_t pmd_mknotpresent(pmd_t pmd)
 }
 
 /*
- * The generic version pmdp_get_and_clear uses a version of pmd_clear() with a
+ * The generic version pmdp_huge_get_and_clear uses a version of pmd_clear() with a
  * different prototype.
  */
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                                      unsigned long address, pmd_t *pmdp)
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                           unsigned long address, pmd_t *pmdp)
 {
        pmd_t old = *pmdp;
 
index 2c118293bccbef4e0ef7db0ec92116a501154870..273fd115cd990fc7b815ead47072a6185f642d8e 100644 (file)
@@ -565,9 +565,9 @@ extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
 extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
                                  unsigned long address, pmd_t *pmdp);
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-extern pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                               unsigned long addr, pmd_t *pmdp);
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+extern pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                    unsigned long addr, pmd_t *pmdp);
 
 #define __HAVE_ARCH_PMDP_SET_WRPROTECT
 static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
index f7775193d745e845df4b2e6b86f9d0de5ceae7fd..876232d641268831c7a1963be7d7d6fbffc55ab1 100644 (file)
@@ -812,8 +812,8 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
        return;
 }
 
-pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                        unsigned long addr, pmd_t *pmdp)
+pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                             unsigned long addr, pmd_t *pmdp)
 {
        pmd_t old_pmd;
        pgtable_t pgtable;
index dba1c6b1a68371edccca66240e00218baf24bf1a..536e857ac0f95c8814a7f60ec43fe6e8d6ae9913 100644 (file)
@@ -1498,9 +1498,9 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
        return pmd_young(pmd);
 }
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                                      unsigned long address, pmd_t *pmdp)
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                           unsigned long address, pmd_t *pmdp)
 {
        pmd_t pmd = *pmdp;
 
@@ -1509,10 +1509,10 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
        return pmd;
 }
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR_FULL
-static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
-                                           unsigned long address,
-                                           pmd_t *pmdp, int full)
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR_FULL
+static inline pmd_t pmdp_huge_get_and_clear_full(struct mm_struct *mm,
+                                                unsigned long address,
+                                                pmd_t *pmdp, int full)
 {
        pmd_t pmd = *pmdp;
 
@@ -1522,11 +1522,11 @@ static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
        return pmd;
 }
 
-#define __HAVE_ARCH_PMDP_CLEAR_FLUSH
-static inline pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
-                                    unsigned long address, pmd_t *pmdp)
+#define __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH
+static inline pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma,
+                                         unsigned long address, pmd_t *pmdp)
 {
-       return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
+       return pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
 }
 
 #define __HAVE_ARCH_PMDP_INVALIDATE
@@ -1552,7 +1552,7 @@ static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,
                                        unsigned long address,
                                        pmd_t *pmdp)
 {
-       return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
+       return pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
 }
 #define pmdp_collapse_flush pmdp_collapse_flush
 
index bc7fc3b36a6d8b4311db3ab83cc977428b18bf17..f4bc48e41e30f466b58b13b2dc3a990922822f06 100644 (file)
@@ -907,10 +907,10 @@ static void maybe_tlb_batch_add(struct mm_struct *mm, unsigned long vaddr,
                tlb_batch_add(mm, vaddr, ptep, orig, fullmm);
 }
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                                      unsigned long addr,
-                                      pmd_t *pmdp)
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                           unsigned long addr,
+                                           pmd_t *pmdp)
 {
        pmd_t pmd = *pmdp;
        set_pmd_at(mm, addr, pmdp, __pmd(0UL));
index 95a4f19d16c52625e40990b2a3d9f0dc0039b84c..2b05ccbebed9b88623871eef69234a24915bcdbb 100644 (file)
@@ -414,10 +414,10 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
 }
 
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                                      unsigned long address,
-                                      pmd_t *pmdp)
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                           unsigned long address,
+                                           pmd_t *pmdp)
 {
        return pte_pmd(ptep_get_and_clear(mm, address, pmdp_ptep(pmdp)));
 }
index fe57e7a98839801ce76a6a33c0f3a7552e5d292a..25add5e44f0a322a76873cd17ef8725beda224ac 100644 (file)
@@ -799,8 +799,8 @@ static inline int pmd_write(pmd_t pmd)
        return pmd_flags(pmd) & _PAGE_RW;
 }
 
-#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, unsigned long addr,
+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr,
                                       pmd_t *pmdp)
 {
        pmd_t pmd = native_pmdp_get_and_clear(pmdp);
index 3b5a89ab4103595b65a62de282bd26c9021035c3..85e2434aeec54430278afd36ccafbfc74ac7731d 100644 (file)
@@ -96,11 +96,11 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
 }
 #endif
 
-#ifndef __HAVE_ARCH_PMDP_GET_AND_CLEAR
+#ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
-                                      unsigned long address,
-                                      pmd_t *pmdp)
+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
+                                           unsigned long address,
+                                           pmd_t *pmdp)
 {
        pmd_t pmd = *pmdp;
        pmd_clear(pmdp);
@@ -109,13 +109,13 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 #endif
 
-#ifndef __HAVE_ARCH_PMDP_GET_AND_CLEAR_FULL
+#ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR_FULL
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-static inline pmd_t pmdp_get_and_clear_full(struct mm_struct *mm,
+static inline pmd_t pmdp_huge_get_and_clear_full(struct mm_struct *mm,
                                            unsigned long address, pmd_t *pmdp,
                                            int full)
 {
-       return pmdp_get_and_clear(mm, address, pmdp);
+       return pmdp_huge_get_and_clear(mm, address, pmdp);
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 #endif
@@ -152,8 +152,8 @@ extern pte_t ptep_clear_flush(struct vm_area_struct *vma,
                              pte_t *ptep);
 #endif
 
-#ifndef __HAVE_ARCH_PMDP_CLEAR_FLUSH
-extern pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
+#ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH
+extern pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma,
                              unsigned long address,
                              pmd_t *pmdp);
 #endif
index 95243d28a0ee72cfaa0abdeb77dfb83bd4738cd9..61cd67f4d7881cbbd8eba481729c06b31d45e9c6 100644 (file)
@@ -324,25 +324,25 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
        ___pte;                                                         \
 })
 
-#define pmdp_clear_flush_notify(__vma, __haddr, __pmd)                 \
+#define pmdp_huge_clear_flush_notify(__vma, __haddr, __pmd)            \
 ({                                                                     \
        unsigned long ___haddr = __haddr & HPAGE_PMD_MASK;              \
        struct mm_struct *___mm = (__vma)->vm_mm;                       \
        pmd_t ___pmd;                                                   \
                                                                        \
-       ___pmd = pmdp_clear_flush(__vma, __haddr, __pmd);               \
+       ___pmd = pmdp_huge_clear_flush(__vma, __haddr, __pmd);          \
        mmu_notifier_invalidate_range(___mm, ___haddr,                  \
                                      ___haddr + HPAGE_PMD_SIZE);       \
                                                                        \
        ___pmd;                                                         \
 })
 
-#define pmdp_get_and_clear_notify(__mm, __haddr, __pmd)                        \
+#define pmdp_huge_get_and_clear_notify(__mm, __haddr, __pmd)           \
 ({                                                                     \
        unsigned long ___haddr = __haddr & HPAGE_PMD_MASK;              \
        pmd_t ___pmd;                                                   \
                                                                        \
-       ___pmd = pmdp_get_and_clear(__mm, __haddr, __pmd);              \
+       ___pmd = pmdp_huge_get_and_clear(__mm, __haddr, __pmd);         \
        mmu_notifier_invalidate_range(__mm, ___haddr,                   \
                                      ___haddr + HPAGE_PMD_SIZE);       \
                                                                        \
@@ -428,8 +428,8 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
 #define ptep_clear_flush_young_notify ptep_clear_flush_young
 #define pmdp_clear_flush_young_notify pmdp_clear_flush_young
 #define        ptep_clear_flush_notify ptep_clear_flush
-#define pmdp_clear_flush_notify pmdp_clear_flush
-#define pmdp_get_and_clear_notify pmdp_get_and_clear
+#define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush
+#define pmdp_huge_get_and_clear_notify pmdp_huge_get_and_clear
 #define set_pte_at_notify set_pte_at
 
 #endif /* CONFIG_MMU_NOTIFIER */
index 6ac8a36f4836ff5d7789dadeba767aaa3346aaf8..639dcb210ac9ecdad1e755fe0238fcce4a910cec 100644 (file)
@@ -1031,7 +1031,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm,
                goto out_free_pages;
        VM_BUG_ON_PAGE(!PageHead(page), page);
 
-       pmdp_clear_flush_notify(vma, haddr, pmd);
+       pmdp_huge_clear_flush_notify(vma, haddr, pmd);
        /* leave pmd empty until pte is filled */
 
        pgtable = pgtable_trans_huge_withdraw(mm, pmd);
@@ -1174,7 +1174,7 @@ alloc:
                pmd_t entry;
                entry = mk_huge_pmd(new_page, vma->vm_page_prot);
                entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
-               pmdp_clear_flush_notify(vma, haddr, pmd);
+               pmdp_huge_clear_flush_notify(vma, haddr, pmd);
                page_add_new_anon_rmap(new_page, vma, haddr);
                mem_cgroup_commit_charge(new_page, memcg, false);
                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,
                pmd_t orig_pmd;
                /*
                 * For architectures like ppc64 we look at deposited pgtable
-                * when calling pmdp_get_and_clear. So do the
+                * when calling pmdp_huge_get_and_clear. So do the
                 * pgtable_trans_huge_withdraw after finishing pmdp related
                 * operations.
                 */
-               orig_pmd = pmdp_get_and_clear_full(tlb->mm, addr, pmd,
-                                                  tlb->fullmm);
+               orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd,
+                                                       tlb->fullmm);
                tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
                pgtable = pgtable_trans_huge_withdraw(tlb->mm, pmd);
                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,
                new_ptl = pmd_lockptr(mm, new_pmd);
                if (new_ptl != old_ptl)
                        spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
-               pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
+               pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
                VM_BUG_ON(!pmd_none(*new_pmd));
 
                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,
                }
 
                if (!prot_numa || !pmd_protnone(*pmd)) {
-                       entry = pmdp_get_and_clear_notify(mm, addr, pmd);
+                       entry = pmdp_huge_get_and_clear_notify(mm, addr, pmd);
                        entry = pmd_modify(entry, newprot);
                        if (preserve_write)
                                entry = pmd_mkwrite(entry);
@@ -2866,7 +2866,7 @@ static void __split_huge_zero_page_pmd(struct vm_area_struct *vma,
        pmd_t _pmd;
        int i;
 
-       pmdp_clear_flush_notify(vma, haddr, pmd);
+       pmdp_huge_clear_flush_notify(vma, haddr, pmd);
        /* leave pmd empty until pte is filled */
 
        pgtable = pgtable_trans_huge_withdraw(mm, pmd);
index 8c4841a6dc4ca5844c595643e03aabe00fec7acb..2585566d3bdfb7eb6024e089c4ff7c5a512d3e7d 100644 (file)
@@ -1796,7 +1796,7 @@ fail_putback:
         */
        flush_cache_range(vma, mmun_start, mmun_end);
        page_add_anon_rmap(new_page, vma, mmun_start);
-       pmdp_clear_flush_notify(vma, mmun_start, pmd);
+       pmdp_huge_clear_flush_notify(vma, mmun_start, pmd);
        set_pmd_at(mm, mmun_start, pmd, entry);
        flush_tlb_range(vma, mmun_start, mmun_end);
        update_mmu_cache_pmd(vma, address, &entry);
index f21dc5fbc6cd76fc10ac30012cbad095a35e1e04..6b674e00153cea664ecadcec49f7c4c35bb843c0 100644 (file)
@@ -119,15 +119,15 @@ pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address,
 }
 #endif
 
-#ifndef __HAVE_ARCH_PMDP_CLEAR_FLUSH
+#ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-pmd_t pmdp_clear_flush(struct vm_area_struct *vma, unsigned long address,
-                      pmd_t *pmdp)
+pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address,
+                           pmd_t *pmdp)
 {
        pmd_t pmd;
        VM_BUG_ON(address & ~HPAGE_PMD_MASK);
        VM_BUG_ON(!pmd_trans_huge(*pmdp));
-       pmd = pmdp_get_and_clear(vma->vm_mm, address, pmdp);
+       pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
        flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
        return pmd;
 }
@@ -205,11 +205,15 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
 pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address,
                          pmd_t *pmdp)
 {
+       /*
+        * pmd and hugepage pte format are same. So we could
+        * use the same function.
+        */
        pmd_t pmd;
 
        VM_BUG_ON(address & ~HPAGE_PMD_MASK);
        VM_BUG_ON(pmd_trans_huge(*pmdp));
-       pmd = pmdp_get_and_clear(vma->vm_mm, address, pmdp);
+       pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
        flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
        return pmd;
 }
index 24dd3f9fee27dfe577c7f605bd0c260f0bc143c7..6f94e4502c495d2d7d7edf93168da5c8ef54e7f9 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -625,7 +625,7 @@ pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address)
 
        pmd = pmd_offset(pud, address);
        /*
-        * Some THP functions use the sequence pmdp_clear_flush(), set_pmd_at()
+        * Some THP functions use the sequence pmdp_huge_clear_flush(), set_pmd_at()
         * without holding anon_vma lock for write.  So when looking for a
         * genuine pmde (in which to find pte), test present and !THP together.
         */