]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/hugetlb: change parameters of arch_make_huge_pte()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 1 Jul 2021 01:48:00 +0000 (18:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 03:47:26 +0000 (20:47 -0700)
Patch series "Subject: [PATCH v2 0/5] Implement huge VMAP and VMALLOC on powerpc 8xx", v2.

This series implements huge VMAP and VMALLOC on powerpc 8xx.

Powerpc 8xx has 4 page sizes:
- 4k
- 16k
- 512k
- 8M

At the time being, vmalloc and vmap only support huge pages which are
leaf at PMD level.

Here the PMD level is 4M, it doesn't correspond to any supported
page size.

For now, implement use of 16k and 512k pages which is done
at PTE level.

Support of 8M pages will be implemented later, it requires use of
hugepd tables.

To allow this, the architecture provides two functions:
- arch_vmap_pte_range_map_size() which tells vmap_pte_range() what
page size to use. A stub returning PAGE_SIZE is provided when the
architecture doesn't provide this function.
- arch_vmap_pte_supported_shift() which tells __vmalloc_node_range()
what page shift to use for a given area size. A stub returning
PAGE_SHIFT is provided when the architecture doesn't provide this
function.

This patch (of 5):

At the time being, arch_make_huge_pte() has the following prototype:

  pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
   struct page *page, int writable);

vma is used to get the pages shift or size.
vma is also used on Sparc to get vm_flags.
page is not used.
writable is not used.

In order to use this function without a vma, replace vma by shift and
flags.  Also remove the used parameters.

Link: https://lkml.kernel.org/r/cover.1620795204.git.christophe.leroy@csgroup.eu
Link: https://lkml.kernel.org/r/f4633ac6a7da2f22f31a04a89e0a7026bb78b15b.1620795204.git.christophe.leroy@csgroup.eu
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/arm64/include/asm/hugetlb.h
arch/arm64/mm/hugetlbpage.c
arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
arch/sparc/include/asm/pgtable_64.h
arch/sparc/mm/hugetlbpage.c
include/linux/hugetlb.h
mm/hugetlb.c
mm/migrate.c

index 5abf91e3494c788e55e7289bec2f20a36f9beca5..1242f71937f80ead96fe32e0cd30c6c30f923c42 100644 (file)
@@ -23,8 +23,7 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 }
 #define arch_clear_hugepage_flags arch_clear_hugepage_flags
 
-extern pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                               struct page *page, int writable);
+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
 #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
 extern void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
index 58987a98e17986811a6fa9803da47d0199fc3534..23505fc353247019e952a2b760dda82677d5fdfe 100644 (file)
@@ -339,10 +339,9 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
        return NULL;
 }
 
-pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                        struct page *page, int writable)
+pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
 {
-       size_t pagesize = huge_page_size(hstate_vma(vma));
+       size_t pagesize = 1UL << shift;
 
        if (pagesize == CONT_PTE_SIZE) {
                entry = pte_mkcont(entry);
index 39be9aea86db6ffc142435a0cf231f0bd499684a..64b6c608eca433b37271cb4d03975264e109504c 100644 (file)
@@ -66,10 +66,9 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
 }
 
 #ifdef CONFIG_PPC_4K_PAGES
-static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                                      struct page *page, int writable)
+static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
 {
-       size_t size = huge_page_size(hstate_vma(vma));
+       size_t size = 1UL << shift;
 
        if (size == SZ_16K)
                return __pte(pte_val(entry) & ~_PAGE_HUGE);
index 550d3904de65b7520abdadf661da0cbfb3ea4548..2cd80a0a97953f55d778995dec624ee0e971dfd8 100644 (file)
@@ -377,8 +377,7 @@ static inline pgprot_t pgprot_noncached(pgprot_t prot)
 #define pgprot_noncached pgprot_noncached
 
 #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
-extern pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                               struct page *page, int writable);
+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
 static inline unsigned long __pte_default_huge_mask(void)
 {
index 04d8790f6c32594479c51c497377fe3cbc064eb6..0f49fada20938c11087cb1811bd06156407d6bbc 100644 (file)
@@ -177,10 +177,8 @@ static pte_t hugepage_shift_to_tte(pte_t entry, unsigned int shift)
                return sun4u_hugepage_shift_to_tte(entry, shift);
 }
 
-pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                        struct page *page, int writeable)
+pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
 {
-       unsigned int shift = huge_page_shift(hstate_vma(vma));
        pte_t pte;
 
        pte = hugepage_shift_to_tte(entry, shift);
@@ -188,7 +186,7 @@ pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 #ifdef CONFIG_SPARC64
        /* If this vma has ADI enabled on it, turn on TTE.mcd
         */
-       if (vma->vm_flags & VM_SPARC_ADI)
+       if (flags & VM_SPARC_ADI)
                return pte_mkmcd(pte);
        else
                return pte_mknotmcd(pte);
index 8c19208442368784b55a84799d4ada8e9eb6e40d..cfde3bec22610d5a8c7a1f03e918939aa32c690b 100644 (file)
@@ -741,8 +741,8 @@ static inline void arch_clear_hugepage_flags(struct page *page) { }
 #endif
 
 #ifndef arch_make_huge_pte
-static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
-                                      struct page *page, int writable)
+static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift,
+                                      vm_flags_t flags)
 {
        return entry;
 }
index dd9c90c082fc419f005aec2332fe1ba0d557d326..88f2178ad7c992921aea02dd93471761d111b8ce 100644 (file)
@@ -4060,6 +4060,7 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
                                int writable)
 {
        pte_t entry;
+       unsigned int shift = huge_page_shift(hstate_vma(vma));
 
        if (writable) {
                entry = huge_pte_mkwrite(huge_pte_mkdirty(mk_huge_pte(page,
@@ -4070,7 +4071,7 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
        }
        entry = pte_mkyoung(entry);
        entry = pte_mkhuge(entry);
-       entry = arch_make_huge_pte(entry, vma, page, writable);
+       entry = arch_make_huge_pte(entry, shift, vma->vm_flags);
 
        return entry;
 }
@@ -5468,10 +5469,11 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
                }
                if (!huge_pte_none(pte)) {
                        pte_t old_pte;
+                       unsigned int shift = huge_page_shift(hstate_vma(vma));
 
                        old_pte = huge_ptep_modify_prot_start(vma, address, ptep);
                        pte = pte_mkhuge(huge_pte_modify(old_pte, newprot));
-                       pte = arch_make_huge_pte(pte, vma, NULL, 0);
+                       pte = arch_make_huge_pte(pte, shift, vma->vm_flags);
                        huge_ptep_modify_prot_commit(vma, address, ptep, old_pte, pte);
                        pages++;
                }
index cc4d6af41683493b5ed4c779e2a15a2386372b8e..75a15f0a2698767afe9dbffdef6ab9e78af3830b 100644 (file)
@@ -226,8 +226,10 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
 
 #ifdef CONFIG_HUGETLB_PAGE
                if (PageHuge(new)) {
+                       unsigned int shift = huge_page_shift(hstate_vma(vma));
+
                        pte = pte_mkhuge(pte);
-                       pte = arch_make_huge_pte(pte, vma, new, 0);
+                       pte = arch_make_huge_pte(pte, shift, vma->vm_flags);
                        set_huge_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte);
                        if (PageAnon(new))
                                hugepage_add_anon_rmap(new, vma, pvmw.address);