Refactor pgalloc stuff
v2 cover Refactor pgalloc stuff
This series converts book3e64 to pte_fragment and refactor things that are common among subarches.
Changes in v2:
- Rebased on latest merge branch (b251649c77625b7ad4430e518dc0f1608be9edf4)
- Resolved conflicts, especially due to the addition of MAX_PHYSMEM_BITS in asm/nohash/64/mmu.h ==> moved it to asm/nohash/mmu-book3e.h
- compilation test at http://kisskb.ellerman.id.au/kisskb/head/cf0b6c1ff5ca934bbe02f88b1b1ba533b386225e/
Christophe Leroy (15):
powerpc/mm: drop __bad_pte()
powerpc/mm: define __pud_free_tlb() at all time on nohash/64 powerpc/mm: convert Book3E 64 to pte_fragment powerpc/mm: move pgtable_t in asm/mmu.h
powerpc/mm: get rid of nohash/32/mmu.h and nohash/64/mmu.h powerpc/Kconfig: select PPC_MM_SLICES from subarch type powerpc/book3e: move early_alloc_pgtable() to init section powerpc/mm: don't use pte_alloc_kernel() until slab is available on
PPC32
powerpc/mm: inline pte_alloc_one_kernel() and pte_alloc_one() on PPC32
powerpc/mm: refactor pte_alloc_one() and pte_free() families
definition.
powerpc/mm: refactor definition of pgtable_cache[]
powerpc/mm: Only keep one version of pmd_populate() functions on
nohash/32 powerpc/mm: refactor pgtable freeing functions on nohash powerpc/mm: refactor pmd_pgtable()
powerpc/mm: refactor pgd_alloc() and pgd_free() on nohash
arch/powerpc/include/asm/book3s/32/mmu-hash.h | 4 - arch/powerpc/include/asm/book3s/32/pgalloc.h | 41 --------- arch/powerpc/include/asm/book3s/64/mmu.h | 8 -- arch/powerpc/include/asm/book3s/64/pgalloc.h | 49 ---------- arch/powerpc/include/asm/mmu.h | 3 + arch/powerpc/include/asm/mmu_context.h | 6 -- arch/powerpc/include/asm/nohash/32/mmu.h | 25 ------ arch/powerpc/include/asm/nohash/32/pgalloc.h | 123 ++------------------------ arch/powerpc/include/asm/nohash/64/mmu.h | 14 --- arch/powerpc/include/asm/nohash/64/pgalloc.h | 117 +----------------------- arch/powerpc/include/asm/nohash/mmu-book3e.h | 2 + arch/powerpc/include/asm/nohash/mmu.h | 16 +++- arch/powerpc/include/asm/nohash/pgalloc.h | 56 ++++++++++++ arch/powerpc/include/asm/pgalloc.h | 51 +++++++++++ arch/powerpc/mm/Makefile | 4 +- arch/powerpc/mm/mmu_context.c | 2 +- arch/powerpc/mm/pgtable-book3e.c | 4 +- arch/powerpc/mm/pgtable_32.c | 42 +++++---- arch/powerpc/platforms/Kconfig.cputype | 4 +- 19 files changed, 167 insertions(+), 404 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/32/mmu.h delete mode 100644 arch/powerpc/include/asm/nohash/64/mmu.h
Signature · 1 line
2.13.3
PATCH v2 1/15 powerpc/mm: drop __bad_pte()
This has never been called (since Kernel has been in git at least), drop it.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 2 -- arch/powerpc/include/asm/nohash/32/pgalloc.h | 2 -- 2 files changed, 4 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -2
@@ -22,8 +22,6 @@*/ #define MAX_PGTABLE_INDEX_SIZE 0xf -extern void __bad_pte (pmd_t *pmd); -extern struct kmem_cache *pgtable_cache[];#define PGT_CACHE (shift) pgtable_cache[shift]
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -2
@@ -22,8 +22,6 @@*/ #define MAX_PGTABLE_INDEX_SIZE 0xf -extern void __bad_pte (pmd_t *pmd); -extern struct kmem_cache *pgtable_cache[];#define PGT_CACHE (shift) pgtable_cache[shift]
Signature · 1 line
2.13.3
Re: [PATCH v2 01/15] powerpc/mm: drop __bad_pte()
Quoted 5 lines · Christophe Leroy
This has never been called (since Kernel has been in git at least), drop it.
Reviewed-by Aneesh Kumar K.V <[email protected]>Signed-off-by Christophe Leroy <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/447def3b06adab60b999417b316bd235
cheers
PATCH v2 2/15 powerpc/mm: define __pud_free_tlb() at all time on nohash/64
In reply to Christophe LeroyCONFIG_PPC_64K_PAGES is not selectable on nohash/64, so get __pud_free_tlb() defined at all time.
--- arch/powerpc/include/asm/nohash/64/pgalloc.h | 3 --- 1 file changed, 3 deletions(-)
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -3
@@ -171,12 +171,9 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,#define __pmd_free_tlb (tlb, pmd, addr) \ pgtable_free_tlb(tlb, pmd, PMD_CACHE_INDEX) -#ifndef CONFIG_PPC_64K_PAGES #define __pud_free_tlb (tlb, pud, addr) \ pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE) -#endif /* CONFIG_PPC_64K_PAGES */ -#define check_pgt_cache () do { } while (0)#endif /* _ASM_POWERPC_PGALLOC_64_H */
Signature · 1 line
2.13.3
PATCH v2 3/15 powerpc/mm: convert Book3E 64 to pte_fragment
In reply to Christophe LeroyBook3E 64 is the only subarch not using pte_fragment. In order to allow refactorisation, this patch converts it to pte_fragment.
--- arch/powerpc/include/asm/mmu_context.h | 6 ----- arch/powerpc/include/asm/nohash/64/mmu.h | 4 +++- arch/powerpc/include/asm/nohash/64/pgalloc.h | 33 ++++++++++------------------ arch/powerpc/mm/Makefile | 4 ++-- arch/powerpc/mm/mmu_context.c | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-)
arch/powerpc/include/asm/mmu_context.h +0 -6
@@ -228,13 +228,7 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,#endif } -#ifdef CONFIG_PPC_BOOK3E_64 -static inline void arch_exit_mmap (struct mm_struct *mm) -{ -} -#else extern void arch_exit_mmap (struct mm_struct *mm); -#endif static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
arch/powerpc/include/asm/nohash/64/mmu.h +3 -1
@@ -4,11 +4,13 @@#define MAX_PHYSMEM_BITS 44 +#include <asm/page.h> +/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ #include <asm/nohash/mmu-book3e.h> #ifndef __ASSEMBLY__ -typedef struct page *pgtable_t ; +typedef pte_t *pgtable_t ;#endif #endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
arch/powerpc/include/asm/nohash/64/pgalloc.h +12 -21
@@ -76,10 +76,10 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd,pgtable_t pte_page) { -pmd_set (pmd, (unsigned long )page_address (pte_page)); +pmd_set (pmd, (unsigned long )pte_page); } -#define pmd_pgtable (pmd) pmd_page(pmd) +#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd))static inline pmd_t *pmd_alloc_one (struct mm_struct *mm,unsigned long addr) {
@@ -92,44 +92,35 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)kmem_cache_free (PGT_CACHE (PMD_CACHE_INDEX ), pmd); } +pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel);static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) { -return (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO); +return (pte_t *)pte_fragment_alloc (mm,1 ); }static inline pgtable_t pte_alloc_one (struct mm_struct *mm) { -struct page *page; -pte_t *pte; - - pte = (pte_t *)__get_free_page (GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT); -if (!pte) -return NULL ; - page =virt_to_page (pte); -if (!pgtable_page_ctor (page)) { -__free_page (page); -return NULL ; - } -return page; +return (pgtable_t )pte_fragment_alloc (mm,0 ); } +void pte_frag_destroy (void *pte_frag); +void pte_fragment_free (unsigned long *table,int kernel); +static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) { -free_page ((unsigned long )pte); +pte_fragment_free ((unsigned long *)pte,1 ); }static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) { -pgtable_page_dtor (ptepage); -__free_page (ptepage); +pte_fragment_free ((unsigned long *)ptepage,0 ); }static inline void pgtable_free (void *table,int shift) {if (!shift) { -pgtable_page_dtor (virt_to_page (table)); -free_page ((unsigned long )table); +pte_fragment_free ((unsigned long *)table,0 ); }else {BUG_ON (shift >MAX_PGTABLE_INDEX_SIZE );kmem_cache_free (PGT_CACHE (shift), table);
@@ -166,7 +157,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, unsigned long address) {tlb_flush_pgtable (tlb, address); -pgtable_free_tlb (tlb,page_address (table),0 ); +pgtable_free_tlb (tlb, table,0 ); }#define __pmd_free_tlb (tlb, pmd, addr) \
arch/powerpc/mm/Makefile +2 -2
@@ -9,6 +9,7 @@ CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) obj-y := fault.o mem.o pgtable.o mmap.o \ init_$(BITS).o pgtable_$(BITS).o \ + pgtable-frag.o \ init-common.o mmu_context.o drmem.o obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o
@@ -17,8 +18,7 @@ hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb.o \ $(hash64-y) mmu_context_book3s64.o \ - pgtable-book3s64.o pgtable-frag.o -obj-$(CONFIG_PPC32) += pgtable-frag.o + pgtable-book3s64.o obj-$(CONFIG_PPC_RADIX_MMU) += pgtable-radix.o tlb-radix.o obj-$(CONFIG_PPC_BOOK3S_32) += ppc_mmu_32.o hash_low_32.o mmu_context_hash32.o obj-$(CONFIG_PPC_BOOK3S) += tlb_hash$(BITS).o
arch/powerpc/mm/mmu_context.c +1 -1
@@ -98,7 +98,7 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,switch_mmu_context (prev, next, tsk); } -#ifdef CONFIG_PPC32 +#ifndef CONFIG_PPC_BOOK3S_64 void arch_exit_mmap (struct mm_struct *mm) {void *frag =pte_frag_get (&mm->context);
Signature · 1 line
2.13.3
Re: [PATCH v2 03/15] powerpc/mm: convert Book3E 64 to pte_fragment
Le 26/04/2019 à 17:58, Christophe Leroy a écrit :
Quoted 13 lines
Book3E 64 is the only subarch not using
pte_fragment. In order to allow refactorisation, this patch converts it topte_fragment.Reviewed-by Aneesh Kumar K.V <[email protected]>Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/mmu_context.h | 6 ----- arch/powerpc/include/asm/nohash/64/mmu.h | 4 +++- arch/powerpc/include/asm/nohash/64/pgalloc.h | 33 ++++++++++------------------ arch/powerpc/mm/Makefile | 4 ++-- arch/powerpc/mm/mmu_context.c | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-)
[...]
Quoted 13 lines
arch/powerpc/mm/Makefile +1
-0@@ -9,6 +9,7 @@ CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) obj-y := fault.o mem.o pgtable.o mmap.o \ init_$(BITS).o pgtable_$(BITS).o \ + pgtable-frag.o \ init-common.o mmu_context.o drmem.o obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o
arch/powerpc/mm/Makefile hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o · line 21
Quoted 6 lines
arch/powerpc/mm/Makefile +1
-2@@ -17,8 +18,7 @@ hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb.o \ $(hash64-y) mmu_context_book3s64.o \ - pgtable-book3s64.o pgtable-frag.o -obj-$(CONFIG_PPC32) += pgtable-frag.o + pgtable-book3s64.o
Looks like the removal of pgtable-frag.o for CONFIG_PPC_BOOK3S_64 didn't survive the merge.
Will send a patch to fix that.
Christophe
Quoted 3 lines
arch/powerpc/mm/Makefile +0
-0obj-$(CONFIG_PPC_RADIX_MMU) += pgtable-radix.o tlb-radix.o obj-$(CONFIG_PPC_BOOK3S_32) += ppc_mmu_32.o hash_low_32.o mmu_context_hash32.o obj-$(CONFIG_PPC_BOOK3S) += tlb_hash$(BITS).o
Michael Ellerman
reviewerRe: [PATCH v2 03/15] powerpc/mm: convert Book3E 64 to pte_fragment
Quoted 22 lines · Christophe Leroy
Le 26/04/2019 à 17:58, Christophe Leroy a écrit :
Quoted 13 lines
Book3E 64 is the only subarch not using
pte_fragment. In order to allow refactorisation, this patch converts it topte_fragment.Reviewed-by Aneesh Kumar K.V <[email protected]>Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/mmu_context.h | 6 ----- arch/powerpc/include/asm/nohash/64/mmu.h | 4 +++- arch/powerpc/include/asm/nohash/64/pgalloc.h | 33 ++++++++++------------------ arch/powerpc/mm/Makefile | 4 ++-- arch/powerpc/mm/mmu_context.c | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-)[...]
Quoted 6 lines
arch/powerpc/mm/Makefile +0
-0@@ -9,6 +9,7 @@ CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE)
Quoted 16 lines
arch/powerpc/mm/Makefile hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o · line 21
Quoted 13 lines
arch/powerpc/mm/Makefile +2
-2obj-y := fault.o mem.o pgtable.o mmap.o \ init_$(BITS).o pgtable_$(BITS).o \ + pgtable-frag.o \ init-common.o mmu_context.o drmem.o obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o@@ -17,8 +18,7 @@ hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb.o \ $(hash64-y) mmu_context_book3s64.o \ - pgtable-book3s64.o pgtable-frag.o -obj-$(CONFIG_PPC32) += pgtable-frag.o + pgtable-book3s64.oLooks like the removal of pgtable-frag.o for
CONFIG_PPC_BOOK3S_64didn't survive the merge.
Hmm, I don't remember having problems there but clearly something went wrong.
Quoted 1 line
Will send a patch to fix that.
Thanks.
cheers
PATCH v2 4/15 powerpc/mm: move pgtable_t in asm/mmu.h
In reply to Christophe Leroypgtable_t is now identical for all subarches, move it to the top level asm/mmu.h
--- arch/powerpc/include/asm/book3s/32/mmu-hash.h | 4 ---- arch/powerpc/include/asm/book3s/64/mmu.h | 8 -------- arch/powerpc/include/asm/mmu.h | 3 +++ arch/powerpc/include/asm/nohash/32/mmu.h | 6 ------ arch/powerpc/include/asm/nohash/64/mmu.h | 6 ------ 5 files changed, 3 insertions(+), 24 deletions(-)
arch/powerpc/include/asm/book3s/32/mmu-hash.h +0 -4
@@ -10,8 +10,6 @@* BATs */ -#include <asm/page.h> -/* Block size masks */ #define BL_128K 0x000#define BL_256K 0x001
@@ -49,8 +47,6 @@ struct ppc_bat {u32 batu; u32 batl; }; - -typedef pte_t *pgtable_t ;#endif /* !__ASSEMBLY__ */ /*
arch/powerpc/include/asm/book3s/64/mmu.h +0 -8
@@ -25,14 +25,6 @@ struct mmu_psize_def { }; };extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ]; - -/* -* For BOOK3s 64 with 4k and 64K linux page size -* we want to use pointers, because the page table -* actually store pfn -*/ -typedef pte_t *pgtable_t ; -#endif /* __ASSEMBLY__ */ /*
arch/powerpc/include/asm/mmu.h +3 -0
@@ -129,6 +129,9 @@#ifndef __ASSEMBLY__#include <linux/bug.h> #include <asm/cputable.h> +#include <asm/page.h> + +typedef pte_t *pgtable_t ;#ifdef CONFIG_PPC_FSL_BOOK3E #include <asm/percpu.h>
arch/powerpc/include/asm/nohash/32/mmu.h +0 -6
@@ -2,8 +2,6 @@#ifndef _ASM_POWERPC_NOHASH_32_MMU_H_#define _ASM_POWERPC_NOHASH_32_MMU_H_ -#include <asm/page.h> -#if defined(CONFIG_40x)/* 40x-style software loaded TLB */ #include <asm/nohash/32/mmu-40x.h>
@@ -18,8 +16,4 @@#include <asm/nohash/32/mmu-8xx.h> #endif -#ifndef __ASSEMBLY__ -typedef pte_t *pgtable_t ; -#endif -#endif /* _ASM_POWERPC_NOHASH_32_MMU_H_ */
arch/powerpc/include/asm/nohash/64/mmu.h +0 -6
@@ -4,13 +4,7 @@#define MAX_PHYSMEM_BITS 44 -#include <asm/page.h> -/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ #include <asm/nohash/mmu-book3e.h> -#ifndef __ASSEMBLY__ -typedef pte_t *pgtable_t ; -#endif -#endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
Signature · 1 line
2.13.3
PATCH v2 5/15 powerpc/mm: get rid of nohash/32/mmu.h and nohash/64/mmu.h
In reply to Christophe LeroyThose files have no real added values, especially the 64 bit which only includes the common book3e mmu.h which is also included from 32 bits side.
So lets do the final inclusion directly from nohash/mmu.h
--- arch/powerpc/include/asm/nohash/32/mmu.h | 19 ------------------- arch/powerpc/include/asm/nohash/64/mmu.h | 10 ---------- arch/powerpc/include/asm/nohash/mmu-book3e.h | 2 ++ arch/powerpc/include/asm/nohash/mmu.h | 16 ++++++++++++---- 4 files changed, 14 insertions(+), 33 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/32/mmu.h delete mode 100644 arch/powerpc/include/asm/nohash/64/mmu.h
arch/powerpc/include/asm/nohash/32/mmu.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_NOHASH_32_MMU_H_ -#define _ASM_POWERPC_NOHASH_32_MMU_H_ - -#if defined(CONFIG_40x) -/* 40x-style software loaded TLB */ -#include <asm/nohash/32/mmu-40x.h> -#elif defined(CONFIG_44x) -/* 44x-style software loaded TLB */ -#include <asm/nohash/32/mmu-44x.h> -#elif defined(CONFIG_PPC_BOOK3E_MMU ) -/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ -#include <asm/nohash/mmu-book3e.h> -#elif defined (CONFIG_PPC_8xx) -/* Motorola/Freescale 8xx software loaded TLB */ -#include <asm/nohash/32/mmu-8xx.h> -#endif - -#endif /* _ASM_POWERPC_NOHASH_32_MMU_H_ */
arch/powerpc/include/asm/nohash/64/mmu.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_NOHASH_64_MMU_H_ -#define _ASM_POWERPC_NOHASH_64_MMU_H_ - -#define MAX_PHYSMEM_BITS 44 - -/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ -#include <asm/nohash/mmu-book3e.h> - -#endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
arch/powerpc/include/asm/nohash/mmu-book3e.h +2 -0
@@ -306,6 +306,8 @@ extern int book3e_htw_mode;#define mmu_cleanup_all NULL +#define MAX_PHYSMEM_BITS 44 +#endif #endif /* !__ASSEMBLY__ */
arch/powerpc/include/asm/nohash/mmu.h +12 -4
@@ -2,10 +2,18 @@#ifndef _ASM_POWERPC_NOHASH_MMU_H_#define _ASM_POWERPC_NOHASH_MMU_H_ -#ifdef CONFIG_PPC64 -#include <asm/nohash/64/mmu.h> -#else -#include <asm/nohash/32/mmu.h> +#if defined(CONFIG_40x) +/* 40x-style software loaded TLB */ +#include <asm/nohash/32/mmu-40x.h> +#elif defined(CONFIG_44x) +/* 44x-style software loaded TLB */ +#include <asm/nohash/32/mmu-44x.h> +#elif defined(CONFIG_PPC_BOOK3E_MMU ) +/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ +#include <asm/nohash/mmu-book3e.h> +#elif defined (CONFIG_PPC_8xx) +/* Motorola/Freescale 8xx software loaded TLB */ +#include <asm/nohash/32/mmu-8xx.h> #endif #endif /* _ASM_POWERPC_NOHASH_MMU_H_ */
Signature · 1 line
2.13.3
PATCH v2 6/15 powerpc/Kconfig: select PPC_MM_SLICES from subarch type
In reply to Christophe LeroyLets select PPC_MM_SLICES from the subarch config item instead of doing it via defaults declaration in the PPC_MM_SLICES item itself.
--- arch/powerpc/platforms/Kconfig.cputype | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/Kconfig.cputype +2 -2
@@ -38,6 +38,7 @@ config PPC_8xx select SYS_SUPPORTS_HUGETLBFS select PPC_HAVE_KUEP select PPC_HAVE_KUAP + select PPC_MM_SLICES if HUGETLB_PAGE config 40x bool "AMCC 40x"
@@ -79,6 +80,7 @@ config PPC_BOOK3S_64 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE select ARCH_SUPPORTS_NUMA_BALANCING select IRQ_WORK + select PPC_MM_SLICES config PPC_BOOK3E_64 bool "Embedded processors"
@@ -397,8 +399,6 @@ config PPC_BOOK3E_MMU config PPC_MM_SLICES bool - default y if PPC_BOOK3S_64 - default y if PPC_8xx && HUGETLB_PAGE config PPC_HAVE_PMU_SUPPORT bool
Signature · 1 line
2.13.3
PATCH v2 7/15 powerpc/book3e: move early_alloc_pgtable() to init section
In reply to Christophe Leroyearly_alloc_pgtable() is only used during init.
--- arch/powerpc/mm/pgtable-book3e.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/pgtable-book3e.c +2 -2
@@ -55,7 +55,7 @@ void vmemmap_remove_mapping(unsigned long start,#endif #endif /* CONFIG_SPARSEMEM_VMEMMAP */ -static __ref void *early_alloc_pgtable (unsigned long size) +static void __init *early_alloc_pgtable (unsigned long size) {void *ptr;
@@ -74,7 +74,7 @@ static __ref void *early_alloc_pgtable(unsigned long size)* map_kernel_page adds an entry to the ioremap page table * and adds an entry to the HPT, possibly bolting it */ -int map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t prot) +int __ref map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t prot) {pgd_t *pgdp;pud_t *pudp;
Signature · 1 line
2.13.3
PATCH v2 8/15 powerpc/mm: don't use pte_alloc_kernel() until slab is available on PPC32
In reply to Christophe LeroyIn the same way as PPC64, implement early allocation functions and avoid calling pte_alloc_kernel() before slab is available.
--- arch/powerpc/mm/pgtable_32.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
arch/powerpc/mm/pgtable_32.c +28 -6
@@ -43,11 +43,8 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */extern char etext[], _stext[], _sinittext[], _einittext[]; -__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm) +pte_t *pte_alloc_one_kernel (struct mm_struct *mm) { -if (!slab_is_available ()) -return memblock_alloc (PTE_FRAG_SIZE ,PTE_FRAG_SIZE ); -return (pte_t *)pte_fragment_alloc (mm,1 ); }
@@ -205,7 +202,29 @@ void iounmap(volatile void __iomem *addr) }EXPORT_SYMBOL (iounmap); -int map_kernel_page (unsigned long va,phys_addr_t pa,pgprot_t prot) +static void __init *early_alloc_pgtable (unsigned long size) +{ +void *ptr =memblock_alloc (size, size); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size, size); + +return ptr; +} + +static pte_t __init *early_pte_alloc_kernel (pmd_t *pmdp,unsigned long va) +{ +if (pmd_none (*pmdp)) { +pte_t *ptep =early_alloc_pgtable (PTE_FRAG_SIZE ); + +pmd_populate_kernel (&init_mm, pmdp, ptep); + } +return pte_offset_kernel (pmdp, va); +} + + +int __ref map_kernel_page (unsigned long va,phys_addr_t pa,pgprot_t prot) {pmd_t *pd;pte_t *pg;
@@ -214,7 +233,10 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot)/* Use upper 10 bits of VA to index the first level map */ pd =pmd_offset (pud_offset (pgd_offset_k (va), va), va);/* Use middle 10 bits of VA to index the second-level map */ - pg =pte_alloc_kernel (pd, va); +if (likely (slab_is_available ())) + pg =pte_alloc_kernel (pd, va); +else + pg =early_pte_alloc_kernel (pd, va);if (pg !=0 ) { err =0 ;/* The PTE should never be already set nor present in the
Signature · 1 line
2.13.3
PATCH v2 9/15 powerpc/mm: inline pte_alloc_one_kernel() and pte_alloc_one() on PPC32
In reply to Christophe Leroypte_alloc_one_kernel() and pte_alloc_one() are simple calls to pte_fragment_alloc(), so they are good candidates for inlining as already done on PPC64.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 15 ++++++++++++--- arch/powerpc/include/asm/nohash/32/pgalloc.h | 15 ++++++++++++--- arch/powerpc/mm/pgtable_32.c | 10 ---------- 3 files changed, 24 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +12 -3
@@ -59,10 +59,19 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -extern pte_t *pte_alloc_one_kernel (struct mm_struct *mm); -extern pgtable_t pte_alloc_one (struct mm_struct *mm); -void pte_frag_destroy (void *pte_frag);pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); + +static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) +{ +return (pte_t *)pte_fragment_alloc (mm,1 ); +} + +static inline pgtable_t pte_alloc_one (struct mm_struct *mm) +{ +return (pgtable_t )pte_fragment_alloc (mm,0 ); +} + +void pte_frag_destroy (void *pte_frag);void pte_fragment_free (unsigned long *table,int kernel);static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte)
arch/powerpc/include/asm/nohash/32/pgalloc.h +12 -3
@@ -77,10 +77,19 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd))#endif -extern pte_t *pte_alloc_one_kernel (struct mm_struct *mm); -extern pgtable_t pte_alloc_one (struct mm_struct *mm); -void pte_frag_destroy (void *pte_frag);pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); + +static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) +{ +return (pte_t *)pte_fragment_alloc (mm,1 ); +} + +static inline pgtable_t pte_alloc_one (struct mm_struct *mm) +{ +return (pgtable_t )pte_fragment_alloc (mm,0 ); +} + +void pte_frag_destroy (void *pte_frag);void pte_fragment_free (unsigned long *table,int kernel);static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte)
arch/powerpc/mm/pgtable_32.c +0 -10
@@ -43,16 +43,6 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */extern char etext[], _stext[], _sinittext[], _einittext[]; -pte_t *pte_alloc_one_kernel (struct mm_struct *mm) -{ -return (pte_t *)pte_fragment_alloc (mm,1 ); -} - -pgtable_t pte_alloc_one (struct mm_struct *mm) -{ -return (pgtable_t )pte_fragment_alloc (mm,0 ); -} -void __iomem *ioremap (phys_addr_t addr,unsigned long size) {
Signature · 1 line
2.13.3
PATCH v2 10/15 powerpc/mm: refactor pte_alloc_one() and pte_free() families definition.
In reply to Christophe LeroyFunctions pte_alloc_one(), pte_alloc_one_kernel(), pte_free(), pte_free_kernel() are identical for the four subarches.
This patch moves their definition in a common place.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 25 ------------------------- arch/powerpc/include/asm/book3s/64/pgalloc.h | 22 ---------------------- arch/powerpc/include/asm/nohash/32/pgalloc.h | 25 ------------------------- arch/powerpc/include/asm/nohash/64/pgalloc.h | 25 ------------------------- arch/powerpc/include/asm/pgalloc.h | 25 +++++++++++++++++++++++++ 5 files changed, 25 insertions(+), 97 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -25
@@ -59,31 +59,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); - -static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) -{ -return (pte_t *)pte_fragment_alloc (mm,1 ); -} - -static inline pgtable_t pte_alloc_one (struct mm_struct *mm) -{ -return (pgtable_t )pte_fragment_alloc (mm,0 ); -} - -void pte_frag_destroy (void *pte_frag); -void pte_fragment_free (unsigned long *table,int kernel); - -static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) -{ -pte_fragment_free ((unsigned long *)pte,1 ); -} - -static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) -{ -pte_fragment_free ((unsigned long *)ptepage,0 ); -} -static inline void pgtable_free (void *table,unsigned index_size) {if (!index_size) {
arch/powerpc/include/asm/book3s/64/pgalloc.h +0 -22
@@ -39,9 +39,7 @@ extern struct vmemmap_backing *vmemmap_list;extern struct kmem_cache *pgtable_cache[];#define PGT_CACHE (shift) pgtable_cache[shift] -extern pte_t *pte_fragment_alloc (struct mm_struct *,int );extern pmd_t *pmd_fragment_alloc (struct mm_struct *,unsigned long ); -extern void pte_fragment_free (unsigned long *,int );extern void pmd_fragment_free (unsigned long *);extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift);#ifdef CONFIG_SMP
@@ -190,26 +188,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd)return (pgtable_t )pmd_page_vaddr (pmd); } -static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) -{ -return (pte_t *)pte_fragment_alloc (mm,1 ); -} - -static inline pgtable_t pte_alloc_one (struct mm_struct *mm) -{ -return (pgtable_t )pte_fragment_alloc (mm,0 ); -} - -static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) -{ -pte_fragment_free ((unsigned long *)pte,1 ); -} - -static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) -{ -pte_fragment_free ((unsigned long *)ptepage,0 ); -} -static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) {
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -25
@@ -77,31 +77,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd))#endif -pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); - -static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) -{ -return (pte_t *)pte_fragment_alloc (mm,1 ); -} - -static inline pgtable_t pte_alloc_one (struct mm_struct *mm) -{ -return (pgtable_t )pte_fragment_alloc (mm,0 ); -} - -void pte_frag_destroy (void *pte_frag); -void pte_fragment_free (unsigned long *table,int kernel); - -static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) -{ -pte_fragment_free ((unsigned long *)pte,1 ); -} - -static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) -{ -pte_fragment_free ((unsigned long *)ptepage,0 ); -} -static inline void pgtable_free (void *table,unsigned index_size) {if (!index_size) {
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -25
@@ -92,31 +92,6 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)kmem_cache_free (PGT_CACHE (PMD_CACHE_INDEX ), pmd); } -pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); - -static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) -{ -return (pte_t *)pte_fragment_alloc (mm,1 ); -} - -static inline pgtable_t pte_alloc_one (struct mm_struct *mm) -{ -return (pgtable_t )pte_fragment_alloc (mm,0 ); -} - -void pte_frag_destroy (void *pte_frag); -void pte_fragment_free (unsigned long *table,int kernel); - -static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) -{ -pte_fragment_free ((unsigned long *)pte,1 ); -} - -static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) -{ -pte_fragment_free ((unsigned long *)ptepage,0 ); -} -static inline void pgtable_free (void *table,int shift) {if (!shift) {
arch/powerpc/include/asm/pgalloc.h +25 -0
@@ -20,6 +20,31 @@ static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)#define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO) +pte_t *pte_fragment_alloc (struct mm_struct *mm,int kernel); + +static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm) +{ +return (pte_t *)pte_fragment_alloc (mm,1 ); +} + +static inline pgtable_t pte_alloc_one (struct mm_struct *mm) +{ +return (pgtable_t )pte_fragment_alloc (mm,0 ); +} + +void pte_frag_destroy (void *pte_frag); +void pte_fragment_free (unsigned long *table,int kernel); + +static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) +{ +pte_fragment_free ((unsigned long *)pte,1 ); +} + +static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) +{ +pte_fragment_free ((unsigned long *)ptepage,0 ); +} +#ifdef CONFIG_PPC_BOOK3S #include <asm/book3s/pgalloc.h> #else
Signature · 1 line
2.13.3
PATCH v2 11/15 powerpc/mm: refactor definition of pgtable_cache[]
In reply to Christophe Leroypgtable_cache[] is the same for the 4 subarches, lets make it common.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 21 --------------------- arch/powerpc/include/asm/book3s/64/pgalloc.h | 22 ---------------------- arch/powerpc/include/asm/nohash/32/pgalloc.h | 21 --------------------- arch/powerpc/include/asm/nohash/64/pgalloc.h | 22 ---------------------- arch/powerpc/include/asm/pgalloc.h | 21 +++++++++++++++++++++ 5 files changed, 21 insertions(+), 86 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -21
@@ -5,26 +5,6 @@#include <linux/threads.h> #include <linux/slab.h> -/* -* Functions that deal with pagetables that could be at any level of -* the table need to be passed an "index_size" so they know how to -* handle allocation. For PTE pages (which are linked to a struct -* page for now, and drawn from the main get_free_pages() pool), the -* allocation size will be (2^index_size * sizeof(pointer)) and -* allocations are drawn from the kmem_cache in PGT_CACHE(index_size). -* -* The maximum index size needs to be big enough to allow any -* pagetable sizes we need, but small enough to fit in the low bits of -* any page table pointer. In other words all pagetables, even tiny -* ones, must be aligned to allow at least enough low 0 bits to -* contain this value. This value is also used as a mask, so it must -* be one less than a power of two. -*/ -#define MAX_PGTABLE_INDEX_SIZE 0xf - -extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE (shift) pgtable_cache[shift] -static inline pgd_t *pgd_alloc (struct mm_struct *mm) { return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
@@ -69,7 +49,6 @@ static inline void pgtable_free(void *table, unsigned index_size) } } -#define check_pgt_cache () do { } while (0)#define get_hugepd_cache_index (x) (x)#ifdef CONFIG_SMP
arch/powerpc/include/asm/book3s/64/pgalloc.h +0 -22
@@ -19,26 +19,6 @@ struct vmemmap_backing { };extern struct vmemmap_backing *vmemmap_list; -/* -* Functions that deal with pagetables that could be at any level of -* the table need to be passed an "index_size" so they know how to -* handle allocation. For PTE pages (which are linked to a struct -* page for now, and drawn from the main get_free_pages() pool), the -* allocation size will be (2^index_size * sizeof(pointer)) and -* allocations are drawn from the kmem_cache in PGT_CACHE(index_size). -* -* The maximum index size needs to be big enough to allow any -* pagetable sizes we need, but small enough to fit in the low bits of -* any page table pointer. In other words all pagetables, even tiny -* ones, must be aligned to allow at least enough low 0 bits to -* contain this value. This value is also used as a mask, so it must -* be one less than a power of two. -*/ -#define MAX_PGTABLE_INDEX_SIZE 0xf - -extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE (shift) pgtable_cache[shift] -extern pmd_t *pmd_fragment_alloc (struct mm_struct *,unsigned long );extern void pmd_fragment_free (unsigned long *);extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift);
@@ -199,8 +179,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,pgtable_free_tlb (tlb, table,PTE_INDEX ); } -#define check_pgt_cache () do { } while (0) -extern atomic_long_t direct_pages_count[MMU_PAGE_COUNT ];static inline void update_page_count (int psize,long count) {
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -21
@@ -5,26 +5,6 @@#include <linux/threads.h> #include <linux/slab.h> -/* -* Functions that deal with pagetables that could be at any level of -* the table need to be passed an "index_size" so they know how to -* handle allocation. For PTE pages (which are linked to a struct -* page for now, and drawn from the main get_free_pages() pool), the -* allocation size will be (2^index_size * sizeof(pointer)) and -* allocations are drawn from the kmem_cache in PGT_CACHE(index_size). -* -* The maximum index size needs to be big enough to allow any -* pagetable sizes we need, but small enough to fit in the low bits of -* any page table pointer. In other words all pagetables, even tiny -* ones, must be aligned to allow at least enough low 0 bits to -* contain this value. This value is also used as a mask, so it must -* be one less than a power of two. -*/ -#define MAX_PGTABLE_INDEX_SIZE 0xf - -extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE (shift) pgtable_cache[shift] -static inline pgd_t *pgd_alloc (struct mm_struct *mm) { return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
@@ -87,7 +67,6 @@ static inline void pgtable_free(void *table, unsigned index_size) } } -#define check_pgt_cache () do { } while (0)#define get_hugepd_cache_index (x) (x)#ifdef CONFIG_SMP
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -22
@@ -18,26 +18,6 @@ struct vmemmap_backing { };extern struct vmemmap_backing *vmemmap_list; -/* -* Functions that deal with pagetables that could be at any level of -* the table need to be passed an "index_size" so they know how to -* handle allocation. For PTE pages (which are linked to a struct -* page for now, and drawn from the main get_free_pages() pool), the -* allocation size will be (2^index_size * sizeof(pointer)) and -* allocations are drawn from the kmem_cache in PGT_CACHE(index_size). -* -* The maximum index size needs to be big enough to allow any -* pagetable sizes we need, but small enough to fit in the low bits of -* any page table pointer. In other words all pagetables, even tiny -* ones, must be aligned to allow at least enough low 0 bits to -* contain this value. This value is also used as a mask, so it must -* be one less than a power of two. -*/ -#define MAX_PGTABLE_INDEX_SIZE 0xf - -extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE (shift) pgtable_cache[shift] -static inline pgd_t *pgd_alloc (struct mm_struct *mm) { return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
@@ -140,6 +120,4 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,#define __pud_free_tlb (tlb, pud, addr) \ pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE) -#define check_pgt_cache () do { } while (0) -#endif /* _ASM_POWERPC_PGALLOC_64_H */
arch/powerpc/include/asm/pgalloc.h +21 -0
@@ -45,6 +45,27 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)pte_fragment_free ((unsigned long *)ptepage,0 ); } +/* +* Functions that deal with pagetables that could be at any level of +* the table need to be passed an "index_size" so they know how to +* handle allocation. For PTE pages, the allocation size will be +* (2^index_size * sizeof(pointer)) and allocations are drawn from +* the kmem_cache in PGT_CACHE(index_size). +* +* The maximum index size needs to be big enough to allow any +* pagetable sizes we need, but small enough to fit in the low bits of +* any page table pointer. In other words all pagetables, even tiny +* ones, must be aligned to allow at least enough low 0 bits to +* contain this value. This value is also used as a mask, so it must +* be one less than a power of two. +*/ +#define MAX_PGTABLE_INDEX_SIZE 0xf + +extern struct kmem_cache *pgtable_cache[]; +#define PGT_CACHE (shift) pgtable_cache[shift] + +static inline void check_pgt_cache (void ) { } +#ifdef CONFIG_PPC_BOOK3S #include <asm/book3s/pgalloc.h> #else
Signature · 1 line
2.13.3
PATCH v2 12/15 powerpc/mm: Only keep one version of pmd_populate() functions on nohash/32
In reply to Christophe LeroyUse IS_ENABLED(CONFIG_BOOKE) to make single versions of pmd_populate() and pmd_populate_kernel()
--- arch/powerpc/include/asm/nohash/32/pgalloc.h | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
arch/powerpc/include/asm/nohash/32/pgalloc.h +8 -20
@@ -25,37 +25,25 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)#define __pmd_free_tlb (tlb,x,a) do { } while (0)/* #define pgd_populate(mm, pmd, pte) BUG() */ -#ifndef CONFIG_BOOKE -static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmdp,pte_t *pte) { - *pmdp =__pmd (__pa (pte) | _PMD_PRESENT); +if (IS_ENABLED (CONFIG_BOOKE )) + *pmdp =__pmd ((unsigned long )pte | _PMD_PRESENT); +else + *pmdp =__pmd (__pa (pte) | _PMD_PRESENT); }static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmdp,pgtable_t pte_page) { - *pmdp =__pmd (__pa (pte_page) | _PMD_USER | _PMD_PRESENT); +if (IS_ENABLED (CONFIG_BOOKE )) + *pmdp =__pmd ((unsigned long )pte_page | _PMD_PRESENT); +else + *pmdp =__pmd (__pa (pte_page) | _PMD_USER | _PMD_PRESENT); }#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -#else - -static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmdp, -pte_t *pte) -{ - *pmdp =__pmd ((unsigned long )pte | _PMD_PRESENT); -} - -static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmdp, -pgtable_t pte_page) -{ - *pmdp =__pmd ((unsigned long )pte_page | _PMD_PRESENT); -} - -#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -#endif static inline void pgtable_free (void *table,unsigned index_size) {
Signature · 1 line
2.13.3
PATCH v2 13/15 powerpc/mm: refactor pgtable freeing functions on nohash
In reply to Christophe Leroypgtable_free() and others are identical on nohash/32 and 64, so move them into asm/nohash/pgalloc.h
--- arch/powerpc/include/asm/nohash/32/pgalloc.h | 43 --------------------------- arch/powerpc/include/asm/nohash/64/pgalloc.h | 43 --------------------------- arch/powerpc/include/asm/nohash/pgalloc.h | 44 ++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 86 deletions(-)
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -43
@@ -45,47 +45,4 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -static inline void pgtable_free (void *table,unsigned index_size) -{ -if (!index_size) { -pte_fragment_free ((unsigned long *)table,0 ); - }else { -BUG_ON (index_size >MAX_PGTABLE_INDEX_SIZE ); -kmem_cache_free (PGT_CACHE (index_size), table); - } -} - -#define get_hugepd_cache_index (x) (x) - -#ifdef CONFIG_SMP -static inline void pgtable_free_tlb (struct mmu_gather *tlb, -void *table,int shift) -{ -unsigned long pgf = (unsigned long )table; -BUG_ON (shift >MAX_PGTABLE_INDEX_SIZE ); - pgf |= shift; -tlb_remove_table (tlb, (void *)pgf); -} - -static inline void __tlb_remove_table (void *_table) -{ -void *table = (void *)((unsigned long )_table & ~MAX_PGTABLE_INDEX_SIZE ); -unsigned shift = (unsigned long )_table &MAX_PGTABLE_INDEX_SIZE ; - -pgtable_free (table, shift); -} -#else -static inline void pgtable_free_tlb (struct mmu_gather *tlb, -void *table,int shift) -{ -pgtable_free (table, shift); -} -#endif - -static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table, -unsigned long address) -{ -tlb_flush_pgtable (tlb, address); -pgtable_free_tlb (tlb, table,0 ); -}#endif /* _ASM_POWERPC_PGALLOC_32_H */
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -43
49 lines not on this page · raw message
arch/powerpc/include/asm/nohash/pgalloc.h +44 -0
48 lines not on this page · raw message
Signature · 1 line
2.13.3
PATCH v2 14/15 powerpc/mm: refactor pmd_pgtable()
In reply to Christophe Leroypmd_pgtable() is identical on the 4 subarches, refactor it.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 2 -- arch/powerpc/include/asm/book3s/64/pgalloc.h | 5 ----- arch/powerpc/include/asm/nohash/32/pgalloc.h | 2 -- arch/powerpc/include/asm/nohash/64/pgalloc.h | 2 -- arch/powerpc/include/asm/pgalloc.h | 5 +++++ 5 files changed, 5 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -2
@@ -37,8 +37,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp, *pmdp =__pmd (__pa (pte_page) | _PMD_PRESENT); } -#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -static inline void pgtable_free (void *table,unsigned index_size) {if (!index_size) {
arch/powerpc/include/asm/book3s/64/pgalloc.h +0 -5
@@ -163,11 +163,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, *pmd =__pmd (__pgtable_ptr_val (pte_page) |PMD_VAL_BITS ); } -static inline pgtable_t pmd_pgtable (pmd_t pmd) -{ -return (pgtable_t )pmd_page_vaddr (pmd); -} -static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) {
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -2
@@ -43,6 +43,4 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp, *pmdp = __pmd(__pa(pte_page) | _PMD_USER | _PMD_PRESENT); } -#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -#endif /* _ASM_POWERPC_PGALLOC_32_H */
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -2
@@ -59,8 +59,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,pmd_set (pmd, (unsigned long )pte_page); } -#define pmd_pgtable (pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -static inline pmd_t *pmd_alloc_one (struct mm_struct *mm,unsigned long addr) { return kmem_cache_alloc(PGT_CACHE(PMD_CACHE_INDEX),
arch/powerpc/include/asm/pgalloc.h +5 -0
@@ -72,4 +72,9 @@ static inline void check_pgt_cache(void) { }#include <asm/nohash/pgalloc.h> #endif +static inline pgtable_t pmd_pgtable (pmd_t pmd) +{ +return (pgtable_t )pmd_page_vaddr (pmd); +} +#endif /* _ASM_POWERPC_PGALLOC_H */
Signature · 1 line
2.13.3
PATCH v2 15/15 powerpc/mm: refactor pgd_alloc() and pgd_free() on nohash
In reply to Christophe Leroypgd_alloc() and pgd_free() are identical on nohash 32 and 64.
--- arch/powerpc/include/asm/nohash/32/pgalloc.h | 11 ----------- arch/powerpc/include/asm/nohash/64/pgalloc.h | 11 ----------- arch/powerpc/include/asm/nohash/pgalloc.h | 12 ++++++++++++ 3 files changed, 12 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/nohash/32/pgalloc.h +0 -11
@@ -5,17 +5,6 @@#include <linux/threads.h> #include <linux/slab.h> -static inline pgd_t *pgd_alloc (struct mm_struct *mm) -{ -return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ), -pgtable_gfp_flags (mm,GFP_KERNEL )); -} - -static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) -{ -kmem_cache_free (PGT_CACHE (PGD_INDEX_SIZE ), pgd); -} -/* * We don't have any real pmd's, and this code never triggers because * the pgd will always be present..
arch/powerpc/include/asm/nohash/64/pgalloc.h +0 -11
@@ -18,17 +18,6 @@ struct vmemmap_backing { };extern struct vmemmap_backing *vmemmap_list; -static inline pgd_t *pgd_alloc (struct mm_struct *mm) -{ -return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ), -pgtable_gfp_flags (mm,GFP_KERNEL )); -} - -static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) -{ -kmem_cache_free (PGT_CACHE (PGD_INDEX_SIZE ), pgd); -} -#define pgd_populate (MM ,PGD ,PUD ) pgd_set(PGD, (unsigned long)PUD)static inline pud_t *pud_alloc_one (struct mm_struct *mm,unsigned long addr)
arch/powerpc/include/asm/nohash/pgalloc.h +12 -0
@@ -3,6 +3,7 @@#define _ASM_POWERPC_NOHASH_PGALLOC_H#include <linux/mm.h> +#include <linux/slab.h> extern void tlb_remove_table (struct mmu_gather *tlb,void *table);#ifdef CONFIG_PPC64
@@ -16,6 +17,17 @@ static inline void tlb_flush_pgtable(struct mmu_gather *tlb, }#endif /* !CONFIG_PPC_BOOK3E */ +static inline pgd_t *pgd_alloc (struct mm_struct *mm) +{ +return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ), +pgtable_gfp_flags (mm,GFP_KERNEL )); +} + +static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) +{ +kmem_cache_free (PGT_CACHE (PGD_INDEX_SIZE ), pgd); +} +#ifdef CONFIG_PPC64 #include <asm/nohash/64/pgalloc.h> #else
Signature · 1 line
2.13.3