powerpc/mm: enable the use of page table cache of order 0
authorChristophe Leroy <christophe.leroy@c-s.fr>
Thu, 29 Nov 2018 14:07:03 +0000 (14:07 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 4 Dec 2018 08:45:01 +0000 (19:45 +1100)
hugepages uses a cache of order 0. Lets allow page tables
of order 0 in the common part in order to avoid open coding
in hugetlb

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/32/pgalloc.h
arch/powerpc/include/asm/book3s/64/pgalloc.h
arch/powerpc/include/asm/nohash/32/pgalloc.h
arch/powerpc/include/asm/nohash/64/pgalloc.h
arch/powerpc/mm/init-common.c

index 0f58e5b9dbe7ebebc391c580ac5dc34cbe63c97f..b5b955eb2fb733685a5c9bef250be58e09bc9faa 100644 (file)
 extern void __bad_pte(pmd_t *pmd);
 
 extern struct kmem_cache *pgtable_cache[];
-#define PGT_CACHE(shift) ({                            \
-                       BUG_ON(!(shift));               \
-                       pgtable_cache[(shift) - 1];     \
-               })
+#define PGT_CACHE(shift) pgtable_cache[shift]
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
index f949dd90af9b585b2ad7ddcb38060ce249d55ffe..4aba625389c47aa2c26010f191304cb07f2ec862 100644 (file)
@@ -37,10 +37,7 @@ extern struct vmemmap_backing *vmemmap_list;
 #define MAX_PGTABLE_INDEX_SIZE 0xf
 
 extern struct kmem_cache *pgtable_cache[];
-#define PGT_CACHE(shift) ({                            \
-                       BUG_ON(!(shift));               \
-                       pgtable_cache[(shift) - 1];     \
-               })
+#define PGT_CACHE(shift) pgtable_cache[shift]
 
 extern pte_t *pte_fragment_alloc(struct mm_struct *, unsigned long, int);
 extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long);
index 7e234582dce5975f798abcdede158b0bf4aa1d29..17963951bdb06570966cae406323f9cbf893551b 100644 (file)
 extern void __bad_pte(pmd_t *pmd);
 
 extern struct kmem_cache *pgtable_cache[];
-#define PGT_CACHE(shift) ({                            \
-                       BUG_ON(!(shift));               \
-                       pgtable_cache[(shift) - 1];     \
-               })
+#define PGT_CACHE(shift) pgtable_cache[shift]
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
index e2d62d033708c4494a5e95d941b8d34cad3ec3e0..e95eb499a1744b5b46ec5ac2d4dd0802b67ed173 100644 (file)
@@ -36,10 +36,7 @@ extern struct vmemmap_backing *vmemmap_list;
 #define MAX_PGTABLE_INDEX_SIZE 0xf
 
 extern struct kmem_cache *pgtable_cache[];
-#define PGT_CACHE(shift) ({                            \
-                       BUG_ON(!(shift));               \
-                       pgtable_cache[(shift) - 1];     \
-               })
+#define PGT_CACHE(shift) pgtable_cache[shift]
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
index 2b656e67f2eaaa3914cd74d1cd57e36a5060486b..41190f2b60c20b070c1d2ac4eb81c3c26db4e115 100644 (file)
@@ -40,7 +40,7 @@ static void pmd_ctor(void *addr)
        memset(addr, 0, PMD_TABLE_SIZE);
 }
 
-struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE];
+struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE + 1];
 EXPORT_SYMBOL_GPL(pgtable_cache);      /* used by kvm_hv module */
 
 /*
@@ -71,7 +71,7 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *))
         * moment, gcc doesn't seem to recognize is_power_of_2 as a
         * constant expression, so so much for that. */
        BUG_ON(!is_power_of_2(minalign));
-       BUG_ON((shift < 1) || (shift > MAX_PGTABLE_INDEX_SIZE));
+       BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
 
        if (PGT_CACHE(shift))
                return; /* Already have a cache of this size */
@@ -83,7 +83,7 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *))
                panic("Could not allocate pgtable cache for order %d", shift);
 
        kfree(name);
-       pgtable_cache[shift - 1] = new;
+       pgtable_cache[shift] = new;
 
        pr_debug("Allocated pgtable cache for order %d\n", shift);
 }