powerpc/8xx: implementation of huge pages
Subsystems (2)
cover powerpc/8xx: implementation of huge pages
This set provides implementation of huge pages on the 8xx
Christophe Leroy (6):
powerpc: port 64 bits pgtable_cache to 32 bits
powerpc: fix usage of _PAGE_RO in hugepage
powerpc/8xx: use r3 to scratch CR in ITLBmiss powerpc/8xx: Move additional DTLBMiss handlers out of exception area powerpc/8xx: make user addr DTLB miss the short path powerpc/8xx: implementation of huge pages
arch/powerpc/include/asm/book3s/32/pgalloc.h | 44 ++++- arch/powerpc/include/asm/book3s/32/pgtable.h | 43 ++--- arch/powerpc/include/asm/book3s/64/pgtable.h | 5 +- arch/powerpc/include/asm/hugetlb.h | 20 ++- arch/powerpc/include/asm/mmu-8xx.h | 35 ++++ arch/powerpc/include/asm/mmu.h | 25 +-- arch/powerpc/include/asm/nohash/32/pgalloc.h | 44 ++++- arch/powerpc/include/asm/nohash/32/pgtable.h | 45 ++--- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 1 + arch/powerpc/include/asm/nohash/64/pgtable.h | 2 - arch/powerpc/include/asm/nohash/pgtable.h | 4 + arch/powerpc/include/asm/pgtable.h | 2 + arch/powerpc/include/asm/reg_8xx.h | 2 +- arch/powerpc/kernel/head_8xx.S | 235 +++++++++++++++++++-------- arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/hugetlbpage.c | 184 ++++++++------------- arch/powerpc/mm/init-common.c | 152 +++++++++++++++++ arch/powerpc/mm/init_32.c | 5 - arch/powerpc/mm/init_64.c | 82 ---------- arch/powerpc/mm/pgtable_32.c | 37 ----- arch/powerpc/mm/tlb_nohash.c | 21 ++- arch/powerpc/platforms/8xx/Kconfig | 1 + arch/powerpc/platforms/Kconfig.cputype | 1 + 23 files changed, 603 insertions(+), 389 deletions(-) create mode 100644 arch/powerpc/mm/init-common.c
Signature · 1 line
2.1.0
PATCH 1/6 powerpc: port 64 bits pgtable_cache to 32 bits
Today powerpc64 uses a set of pgtable_caches while powerpc32 uses standard pages when using 4k pages and a single pgtable_cache if using other size pages. In addition powerpc32 uses another cache when handling huge pages.
In preparation of implementing huge pages on the 8xx, this patch replaces the specific powerpc32 handling by the 64 bits approach.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 44 ++++++-- arch/powerpc/include/asm/book3s/32/pgtable.h | 43 ++++---- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 - arch/powerpc/include/asm/hugetlb.h | 2 - arch/powerpc/include/asm/nohash/32/pgalloc.h | 44 ++++++-- arch/powerpc/include/asm/nohash/32/pgtable.h | 45 ++++---- arch/powerpc/include/asm/nohash/64/pgtable.h | 2 - arch/powerpc/include/asm/pgtable.h | 2 + arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/hugetlbpage.c | 12 +-- arch/powerpc/mm/init-common.c | 152 +++++++++++++++++++++++++++ arch/powerpc/mm/init_32.c | 5 - arch/powerpc/mm/init_64.c | 82 --------------- arch/powerpc/mm/pgtable_32.c | 37 ------- 14 files changed, 282 insertions(+), 193 deletions(-) create mode 100644 arch/powerpc/mm/init-common.c
arch/powerpc/include/asm/book3s/32/pgalloc.h +38 -6
@@ -2,14 +2,42 @@#define _ASM_POWERPC_BOOK3S_32_PGALLOC_H#include <linux/threads.h> +#include <linux/slab.h> -/* For 32-bit, all levels of page tables are just drawn from get_free_page() */ -#define MAX_PGTABLE_INDEX_SIZE 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 (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 0xfextern void __bad_pte (pmd_t *pmd); -extern pgd_t *pgd_alloc (struct mm_struct *mm); -extern void pgd_free (struct mm_struct *mm,pgd_t *pgd); +extern struct kmem_cache *pgtable_cache[]; +#define PGT_CACHE (shift) ({ \ + BUG_ON(!(shift)); \ + pgtable_cache[(shift) - 1]; \ + }) + +static inline pgd_t *pgd_alloc (struct mm_struct *mm) +{ +return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),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
@@ -68,8 +96,12 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)static inline void pgtable_free (void *table,unsigned index_size) { -BUG_ON (index_size);/* 32-bit doesn't use this */ -free_page ((unsigned long )table); +if (!index_size) +free_page ((unsigned long )table); +else { +BUG_ON (index_size >MAX_PGTABLE_INDEX_SIZE ); +kmem_cache_free (PGT_CACHE (index_size), table); + } }#define check_pgt_cache () do { } while (0)
arch/powerpc/include/asm/book3s/32/pgtable.h +23 -20
70 lines not on this page · raw message
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -3
@@ -786,9 +786,6 @@ extern struct page *pgd_page(pgd_t pgd);#define pgd_ERROR (e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); -void pgtable_cache_init (void ); -static inline int map_kernel_page (unsigned long ea,unsigned long pa,unsigned long flags) {
arch/powerpc/include/asm/hugetlb.h +0 -2
@@ -5,8 +5,6 @@#include <asm/page.h> #include <asm-generic/hugetlb.h> -extern struct kmem_cache *hugepte_cache; -#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/hugetlb-radix.h>
arch/powerpc/include/asm/nohash/32/pgalloc.h +38 -6
60 lines not on this page · raw message
arch/powerpc/include/asm/nohash/32/pgtable.h +23 -22
66 lines not on this page · raw message
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -2
@@ -357,8 +357,6 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val((pte)) })#define __swp_entry_to_pte (x) __pte((x).val) -void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); -void pgtable_cache_init (void );extern int map_kernel_page (unsigned long ea,unsigned long pa,unsigned long flags); extern int __meminit vmemmap_create_mapping(unsigned long start,
arch/powerpc/include/asm/pgtable.h +2 -0
@@ -78,6 +78,8 @@ static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,unsigned long vmalloc_to_phys (void *vmalloc_addr); +void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); +void pgtable_cache_init (void );#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */
arch/powerpc/mm/Makefile +1 -1
@@ -7,7 +7,7 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) obj-y := fault.o mem.o pgtable.o mmap.o \ - init_$(CONFIG_WORD_SIZE).o \ + init_$(CONFIG_WORD_SIZE).o init-common.o \ pgtable_$(CONFIG_WORD_SIZE).o obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.o
arch/powerpc/mm/hugetlbpage.c +5 -7
@@ -68,7 +68,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,#ifdef CONFIG_PPC_FSL_BOOK3E int i;int num_hugepd =1 << (pshift - pdshift); - cachep = hugepte_cache; + cachep =PGT_CACHE (1 );#else cachep =PGT_CACHE (pdshift - pshift);#endif
@@ -411,7 +411,7 @@ static void hugepd_free_rcu_callback(struct rcu_head *head)unsigned int i;for (i =0 ; i < batch->index; i++) -kmem_cache_free (hugepte_cache, batch->ptes[i]); +kmem_cache_free (PGT_CACHE (1 ), batch->ptes[i]);free_page ((unsigned long )batch); }
@@ -425,7 +425,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte)if (atomic_read (&tlb->mm->mm_users) <2 ||cpumask_equal (mm_cpumask (tlb->mm),cpumask_of (smp_processor_id ()))) { -kmem_cache_free (hugepte_cache, hugepte); +kmem_cache_free (PGT_CACHE (1 ), hugepte);put_cpu_var (hugepd_freelist_cur);return ; }
@@ -792,7 +792,6 @@ static int __init hugepage_setup_sz(char *str)__setup ("hugepagesz=" , hugepage_setup_sz);#ifdef CONFIG_PPC_FSL_BOOK3E -struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ) {int psize;
@@ -815,9 +814,8 @@ static int __init hugetlbpage_init(void)* Create a kmem cache for hugeptes. The bottom bits in the pte have * size information encoded in them, so align them to allow this */ - hugepte_cache =kmem_cache_create ("hugepte-cache" ,sizeof (pte_t), -HUGEPD_SHIFT_MASK +1 ,0 ,NULL ); -if (hugepte_cache ==NULL ) +pgtable_cache_add (1 ,NULL ); +if (!PGT_CACHE (1 ))panic ("%s: Unable to create kmem cache for hugeptes\n" , __func__);
arch/powerpc/mm/init-common.c new file +152 -0
152 lines not on this page · raw message
arch/powerpc/mm/init_32.c +0 -5
@@ -59,11 +59,6 @@phys_addr_t total_memory;phys_addr_t total_lowmem; -phys_addr_t memstart_addr = (phys_addr_t )~0ull ; -EXPORT_SYMBOL (memstart_addr); -phys_addr_t kernstart_addr; -EXPORT_SYMBOL (kernstart_addr); -#ifdef CONFIG_RELOCATABLE /* Used in __va()/__pa() */ long long virt_phys_offset;
arch/powerpc/mm/init_64.c +0 -82
88 lines not on this page · raw message
arch/powerpc/mm/pgtable_32.c +0 -37
@@ -42,43 +42,6 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */extern char etext[], _stext[], _sinittext[], _einittext[]; -#define PGDIR_ORDER (32 + PGD_T_LOG2 - PGDIR_SHIFT) - -#ifndef CONFIG_PPC_4K_PAGES -static struct kmem_cache *pgtable_cache; - -void pgtable_cache_init (void ) -{ - pgtable_cache =kmem_cache_create ("PGDIR cache" ,1 <<PGDIR_ORDER , -1 <<PGDIR_ORDER ,0 ,NULL ); -if (pgtable_cache ==NULL ) -panic ("Couldn't allocate pgtable caches" ); -} -#endif - -pgd_t *pgd_alloc (struct mm_struct *mm) -{ -pgd_t *ret; - -/* pgdir take page or two with 4K pages and a page fraction otherwise */ -#ifndef CONFIG_PPC_4K_PAGES - ret =kmem_cache_alloc (pgtable_cache,GFP_KERNEL | __GFP_ZERO); -#else - ret = (pgd_t *)__get_free_pages (GFP_KERNEL |__GFP_ZERO, -PGDIR_ORDER -PAGE_SHIFT ); -#endif -return ret; -} - -void pgd_free (struct mm_struct *mm,pgd_t *pgd) -{ -#ifndef CONFIG_PPC_4K_PAGES -kmem_cache_free (pgtable_cache, (void *)pgd); -#else -free_pages ((unsigned long )pgd,PGDIR_ORDER -PAGE_SHIFT ); -#endif -} -__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm,unsigned long address) {pte_t *pte;
Signature · 1 line
2.1.0
PATCH 2/6 powerpc: fix usage of _PAGE_RO in hugepage
In reply to Christophe Leroy--- arch/powerpc/include/asm/book3s/64/pgtable.h | 2 ++ arch/powerpc/mm/hugetlbpage.c | 2 ++ 2 files changed, 4 insertions(+)
arch/powerpc/include/asm/book3s/64/pgtable.h +2 -0
@@ -6,6 +6,8 @@*/ #define _PAGE_BIT_SWAP_TYPE 0 +#define _PAGE_RO 0 +#define _PAGE_EXEC 0x00001/* execute permission */ #define _PAGE_WRITE 0x00002/* write access allowed */ #define _PAGE_READ 0x00004/* read access allowed */
arch/powerpc/mm/hugetlbpage.c +2 -0
@@ -1019,6 +1019,8 @@ int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, mask = _PAGE_PRESENT | _PAGE_READ;if (write) mask |= _PAGE_WRITE; +else + mask |= _PAGE_RO;if ((pte_val (pte) & mask) != mask)return 0 ;
Signature · 1 line
2.1.0
PATCH 3/6 powerpc/8xx: use r3 to scratch CR in ITLBmiss
In reply to Christophe Leroy--- arch/powerpc/kernel/head_8xx.S | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
arch/powerpc/kernel/head_8xx.S +9 -12
@@ -322,7 +322,7 @@ SystemCall: #endif InstructionTLBMiss: -#ifdef CONFIG_8xx_CPU6 +#if defined(CONFIG_8xx_CPU6) || defined(CONFIG_MODULES) || defined (CONFIG_DEBUG_PAGEALLOC) mtspr SPRN_SPRG_SCRATCH2, r3 #endif EXCEPTION_PROLOG_0
@@ -330,23 +330,20 @@ InstructionTLBMiss: /* If we are faulting a kernel address, we have to use the * kernel page tables. */ + mfspr r10, SPRN_SRR0 /* Get effective address of fault */ + INVALIDATE_ADJACENT_PAGES_CPU15(r11, r10) #if defined(CONFIG_MODULES) || defined (CONFIG_DEBUG_PAGEALLOC) /* Only modules will cause ITLB Misses as we always * pin the first 8MB of kernel memory */ - mfspr r11, SPRN_SRR0 /* Get effective address of fault */ - INVALIDATE_ADJACENT_PAGES_CPU15(r10, r11) - mfcr r10 - IS_KERNEL(r11, r11) + mfcr r3 + IS_KERNEL(r11, r10) +#endif mfspr r11, SPRN_M_TW /* Get level 1 table */ +#if defined(CONFIG_MODULES) || defined (CONFIG_DEBUG_PAGEALLOC) BRANCH_UNLESS_KERNEL(3f) lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha 3: - mtcr r10 - mfspr r10, SPRN_SRR0 /* Get effective address of fault */ -#else - mfspr r10, SPRN_SRR0 /* Get effective address of fault */ - INVALIDATE_ADJACENT_PAGES_CPU15(r11, r10) - mfspr r11, SPRN_M_TW /* Get level 1 table base address */ + mtcr r3 #endif /* Insert level 1 index */ rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29
@@ -378,7 +375,7 @@ InstructionTLBMiss: MTSPR_CPU6(SPRN_MI_RPN, r10, r3) /* Update TLB entry */ /* Restore registers */ -#ifdef CONFIG_8xx_CPU6 +#if defined(CONFIG_8xx_CPU6) || defined(CONFIG_MODULES) || defined (CONFIG_DEBUG_PAGEALLOC) mfspr r3, SPRN_SPRG_SCRATCH2 #endif EXCEPTION_EPILOG_0
Signature · 1 line
2.1.0
PATCH 4/6 powerpc/8xx: Move additional DTLBMiss handlers out of exception area
In reply to Christophe LeroyWhen all options are activated, there is not enough space for the DTLBMiss handlers that handles IMMR area and linear RAM pages in the exception area. So lets move them after .0x2000
--- arch/powerpc/kernel/head_8xx.S | 84 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-)
arch/powerpc/kernel/head_8xx.S +42 -42
@@ -381,26 +381,6 @@ InstructionTLBMiss: EXCEPTION_EPILOG_0 rfi -/* - * Bottom part of DataStoreTLBMiss handler for IMMR area - * not enough space in the DataStoreTLBMiss area - */ -DTLBMissIMMR: - mtcr r10 - /* Set 512k byte guarded page and mark it valid */ - li r10, MD_PS512K | MD_GUARDED | MD_SVALID - MTSPR_CPU6(SPRN_MD_TWC, r10, r11) - mfspr r10, SPRN_IMMR /* Get current IMMR */ - rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */ - ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ - _PAGE_PRESENT | _PAGE_NO_CACHE - MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ - - li r11, RPN_PATTERN - mtspr SPRN_DAR, r11 /* Tag DAR */ - EXCEPTION_EPILOG_0 - rfi - . = 0x1200 DataStoreTLBMiss: EXCEPTION_PROLOG_0
@@ -419,7 +399,7 @@ DataStoreTLBMiss: _ENTRY(DTLBMiss_jmp) beq- DTLBMissIMMR #endif - bge- cr7, 4f + bge- cr7, DTLBMissLinear mfspr r11, SPRN_M_TW /* Get level 1 table */ 3:
@@ -486,27 +466,6 @@ _ENTRY(DTLBMiss_jmp) EXCEPTION_EPILOG_0 rfi -4: -_ENTRY(DTLBMiss_cmp) - cmpli cr0, r11, (PAGE_OFFSET + 0x1800000)@h - lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha - bge- 3b - - mtcr r10 - /* Set 8M byte page and mark it valid */ - li r10, MD_PS8MEG | MD_SVALID - MTSPR_CPU6(SPRN_MD_TWC, r10, r11) - mfspr r10, SPRN_MD_EPN - rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */ - ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ - _PAGE_PRESENT - MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ - - li r11, RPN_PATTERN - mtspr SPRN_DAR, r11 /* Tag DAR */ - EXCEPTION_EPILOG_0 - rfi - /* This is an instruction TLB error on the MPC8xx. This could be due * to many reasons, such as executing guarded memory or illegal instruction
@@ -568,6 +527,47 @@ DARFixed:/* Return from dcbx instruction bug workaround */ . = 0x2000 +/* + * Bottom part of DataStoreTLBMiss handlers for IMMR area and linear RAM. + * not enough space in the DataStoreTLBMiss area. + */ +DTLBMissIMMR: + mtcr r10 + /* Set 512k byte guarded page and mark it valid */ + li r10, MD_PS512K | MD_GUARDED | MD_SVALID + MTSPR_CPU6(SPRN_MD_TWC, r10, r11) + mfspr r10, SPRN_IMMR /* Get current IMMR */ + rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */ + ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ + _PAGE_PRESENT | _PAGE_NO_CACHE + MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ + + li r11, RPN_PATTERN + mtspr SPRN_DAR, r11 /* Tag DAR */ + EXCEPTION_EPILOG_0 + rfi + +DTLBMissLinear: +_ENTRY(DTLBMiss_cmp) + cmpli cr0, r11, (PAGE_OFFSET + 0x1800000)@h + lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha + bge- 3b + + mtcr r10 + /* Set 8M byte page and mark it valid */ + li r10, MD_PS8MEG | MD_SVALID + MTSPR_CPU6(SPRN_MD_TWC, r10, r11) + mfspr r10, SPRN_MD_EPN + rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */ + ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ + _PAGE_PRESENT + MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ + + li r11, RPN_PATTERN + mtspr SPRN_DAR, r11 /* Tag DAR */ + EXCEPTION_EPILOG_0 + rfi + /* This is the procedure to calculate the data EA for buggy dcbx,dcbi instructions * by decoding the registers used by the dcbx instruction and adding them. * DAR is set to the calculated address.
Signature · 1 line
2.1.0
PATCH 5/6 powerpc/8xx: make user addr DTLB miss the short path
In reply to Christophe LeroyUser space DTLB miss represent approximatly 90% of TLB misses so make it the shortest path.
Also remove an unneccessary double jump in FixupDAR
Before this patch, we spend 3.3 TB ticks in the handler for each user address miss and 3.4 TB ticks for each kernel address miss After this patch, we send 3.0 TB ticks in the handler for each user address miss and 3.9 TB ticks for each kernel address miss Taking into account that user misses represent 90% of the total, this patch provides an improvement of approx. 9%
--- arch/powerpc/kernel/head_8xx.S | 53 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 30 deletions(-)
arch/powerpc/kernel/head_8xx.S +23 -30
@@ -383,30 +383,31 @@ InstructionTLBMiss: . = 0x1200 DataStoreTLBMiss: + mtspr SPRN_SPRG_SCRATCH2, r3 EXCEPTION_PROLOG_0 - mfcr r10 + mfcr r3 /* If we are faulting a kernel address, we have to use the * kernel page tables. */ - mfspr r11, SPRN_MD_EPN - rlwinm r11, r11, 16, 0xfff8 + mfspr r10, SPRN_MD_EPN + rlwinm r10, r10, 16, 0xfff8 + cmpli cr0, r10, PAGE_OFFSET@h + mfspr r11, SPRN_M_TW /* Get level 1 table */ + blt+ 3f #ifndef CONFIG_PIN_TLB_IMMR - cmpli cr0, r11, VIRT_IMMR_BASE@h + cmpli cr0, r10, VIRT_IMMR_BASE@h #endif - cmpli cr7, r11, PAGE_OFFSET@h +_ENTRY(DTLBMiss_cmp) + cmpli cr7, r10, (PAGE_OFFSET + 0x1800000)@h + lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha #ifndef CONFIG_PIN_TLB_IMMR _ENTRY(DTLBMiss_jmp) beq- DTLBMissIMMR #endif - bge- cr7, DTLBMissLinear - - mfspr r11, SPRN_M_TW /* Get level 1 table */ + blt cr7, DTLBMissLinear 3: - mtcr r10 -#ifdef CONFIG_8xx_CPU6 - mtspr SPRN_SPRG_SCRATCH2, r3 -#endif + mtcr r3 mfspr r10, SPRN_MD_EPN /* Insert level 1 index */
@@ -459,9 +460,7 @@ _ENTRY(DTLBMiss_jmp) MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */ /* Restore registers */ -#ifdef CONFIG_8xx_CPU6 mfspr r3, SPRN_SPRG_SCRATCH2 -#endif mtspr SPRN_DAR, r11 /* Tag DAR */ EXCEPTION_EPILOG_0 rfi
@@ -532,7 +531,7 @@ DARFixed:/* Return from dcbx instruction bug workaround */ * not enough space in the DataStoreTLBMiss area. */ DTLBMissIMMR: - mtcr r10 + mtcr r3 /* Set 512k byte guarded page and mark it valid */ li r10, MD_PS512K | MD_GUARDED | MD_SVALID MTSPR_CPU6(SPRN_MD_TWC, r10, r11)
@@ -544,27 +543,23 @@ DTLBMissIMMR: li r11, RPN_PATTERN mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r3, SPRN_SPRG_SCRATCH2 EXCEPTION_EPILOG_0 rfi DTLBMissLinear: -_ENTRY(DTLBMiss_cmp) - cmpli cr0, r11, (PAGE_OFFSET + 0x1800000)@h - lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha - bge- 3b - - mtcr r10 + mtcr r3 /* Set 8M byte page and mark it valid */ - li r10, MD_PS8MEG | MD_SVALID - MTSPR_CPU6(SPRN_MD_TWC, r10, r11) - mfspr r10, SPRN_MD_EPN - rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */ + li r11, MD_PS8MEG | MD_SVALID + MTSPR_CPU6(SPRN_MD_TWC, r11, r3) + rlwinm r10, r10, 16, 0x0f800000 /* 8xx supports max 256Mb RAM */ ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ _PAGE_PRESENT MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ li r11, RPN_PATTERN mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r3, SPRN_SPRG_SCRATCH2 EXCEPTION_EPILOG_0 rfi
@@ -584,7 +579,9 @@ FixupDAR:/* Entry point for dcbx workaround. */ rlwinm r11, r10, 16, 0xfff8 _ENTRY(FixupDAR_cmp) cmpli cr7, r11, (PAGE_OFFSET + 0x1800000)@h - blt- cr7, 200f + /* create physical page address from effective address */ + tophys(r11, r10) + blt- cr7, 201f lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha /* Insert level 1 index */ 3: rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29
@@ -614,10 +611,6 @@ _ENTRY(FixupDAR_cmp) 141: mfspr r10,SPRN_SPRG_SCRATCH2 b DARFixed /* Nope, go back to normal TLB processing */ - /* create physical page address from effective address */ -200: tophys(r11, r10) - b 201b - 144: mfspr r10, SPRN_DSISR rlwinm r10, r10,0,7,5 /* Clear store bit for buggy dcbst insn */ mtspr SPRN_DSISR, r10
Signature · 1 line
2.1.0
PATCH 6/6 powerpc/8xx: implementation of huge pages
In reply to Christophe LeroyThe 8xx has 512k and 8M pages. This patch implements hugepages using those sizes.
On the 8xx, the size of pages is in the PGD entry, using PS field (bits 28-29):
00 : Small pages (4k or 16k)
01 : 512k pages
10 : reserved
11 : 8M pages
The implementation uses a mix of what is used on BOOKS and BOOKE, as 512k pages are in HUGEPTE tables while for 8M pages we have several PGD entries pointing on a leaf HUGEPTE entry
For the time being, we do not support CPU15 ERRATA if HUGETLB is selected
--- arch/powerpc/include/asm/hugetlb.h | 18 ++- arch/powerpc/include/asm/mmu-8xx.h | 35 ++++++ arch/powerpc/include/asm/mmu.h | 25 ++-- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 1 + arch/powerpc/include/asm/nohash/pgtable.h | 4 + arch/powerpc/include/asm/reg_8xx.h | 2 +- arch/powerpc/kernel/head_8xx.S | 119 +++++++++++++++++- arch/powerpc/mm/hugetlbpage.c | 176 ++++++++++----------------- arch/powerpc/mm/tlb_nohash.c | 21 +++- arch/powerpc/platforms/8xx/Kconfig | 1 + arch/powerpc/platforms/Kconfig.cputype | 1 + 11 files changed, 267 insertions(+), 136 deletions(-)
arch/powerpc/include/asm/hugetlb.h +17 -1
@@ -49,12 +49,20 @@ static inline void __local_flush_hugetlb_page(struct vm_area_struct *vma,static inline pte_t *hugepd_page (hugepd_t hpd) {BUG_ON (!hugepd_ok (hpd)); +#ifdef CONFIG_PPC_8xx +return (pte_t *)__va (hpd.pd & ~(_PMD_PAGE_MASK | _PMD_PRESENT_MASK)); +#else return (pte_t *)((hpd.pd & ~HUGEPD_SHIFT_MASK ) |PD_HUGE ); +#endif }static inline unsigned int hugepd_shift (hugepd_t hpd) { +#ifdef CONFIG_PPC_8xx +return ((hpd.pd & _PMD_PAGE_MASK) >>1 ) +17 ; +#else return hpd.pd &HUGEPD_SHIFT_MASK ; +#endif }#endif /* CONFIG_PPC_BOOK3S_64 */
@@ -97,7 +105,14 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,void book3e_hugetlb_preload (struct vm_area_struct *vma,unsigned long ea,pte_t pte); +#ifdef CONFIG_PPC_8xx +static inline void flush_hugetlb_page (struct vm_area_struct *vma,unsigned long vmaddr) +{ +flush_tlb_page (vma, vmaddr); +} +#else void flush_hugetlb_page (struct vm_area_struct *vma,unsigned long vmaddr); +#endif void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr, unsigned long end, unsigned long floor,
@@ -203,7 +218,8 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,* are reserved early in the boot process by memblock instead of via * the .dts as on IBM platforms. */ -#if defined(CONFIG_HUGETLB_PAGE ) && defined(CONFIG_PPC_FSL_BOOK3E ) +#if defined(CONFIG_HUGETLB_PAGE ) && (defined(CONFIG_PPC_FSL_BOOK3E ) || \ + defined(CONFIG_PPC_8xx))extern void __init reserve_hugetlb_gpages (void );#else static inline void reserve_hugetlb_gpages (void )
arch/powerpc/include/asm/mmu-8xx.h +35 -0
@@ -172,6 +172,41 @@ typedef struct {#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE)) + +/* Page size definitions, common between 32 and 64-bit +* +* shift : is the "PAGE_SHIFT" value for that page size +* penc : is the pte encoding mask +* +*/ +struct mmu_psize_def +{ +unsigned int shift;/* number of bits */ +unsigned int enc;/* PTE encoding */ +unsigned int ind;/* Corresponding indirect page size shift */ +unsigned int flags; +#define MMU_PAGE_SIZE_DIRECT 0x1/* Supported as a direct size */ +#define MMU_PAGE_SIZE_INDIRECT 0x2/* Supported as an indirect size */ +}; +extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ]; + +static inline int shift_to_mmu_psize (unsigned int shift) +{ +int psize; + +for (psize =0 ; psize <MMU_PAGE_COUNT ; ++psize) +if (mmu_psize_defs[psize].shift == shift) +return psize; +return -1 ; +} + +static inline unsigned int mmu_psize_to_shift (unsigned int mmu_psize) +{ +if (mmu_psize_defs[mmu_psize].shift) +return mmu_psize_defs[mmu_psize].shift; +BUG (); +} +#endif /* !__ASSEMBLY__ */ #if defined(CONFIG_PPC_4K_PAGES )
arch/powerpc/include/asm/mmu.h +13 -12
@@ -260,18 +260,19 @@ static inline bool early_radix_enabled(void)#define MMU_PAGE_64K 2#define MMU_PAGE_64K_AP 3/* "Admixed pages" (hash64 only) */ #define MMU_PAGE_256K 4 -#define MMU_PAGE_1M 5 -#define MMU_PAGE_2M 6 -#define MMU_PAGE_4M 7 -#define MMU_PAGE_8M 8 -#define MMU_PAGE_16M 9 -#define MMU_PAGE_64M 10 -#define MMU_PAGE_256M 11 -#define MMU_PAGE_1G 12 -#define MMU_PAGE_16G 13 -#define MMU_PAGE_64G 14 - -#define MMU_PAGE_COUNT 15 +#define MMU_PAGE_512K 5 +#define MMU_PAGE_1M 6 +#define MMU_PAGE_2M 7 +#define MMU_PAGE_4M 8 +#define MMU_PAGE_8M 9 +#define MMU_PAGE_16M 10 +#define MMU_PAGE_64M 11 +#define MMU_PAGE_256M 12 +#define MMU_PAGE_1G 13 +#define MMU_PAGE_16G 14 +#define MMU_PAGE_64G 15 + +#define MMU_PAGE_COUNT 16#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/mmu.h>
arch/powerpc/include/asm/nohash/32/pte-8xx.h +1 -0
@@ -49,6 +49,7 @@#define _PMD_BAD 0x0ff0#define _PMD_PAGE_MASK 0x000c#define _PMD_PAGE_8M 0x000c +#define _PMD_PAGE_512K 0x0004/* Until my rework is finished, 8xx still needs atomic PTE updates */ #define PTE_ATOMIC_UPDATES 1
arch/powerpc/include/asm/nohash/pgtable.h +4 -0
@@ -226,7 +226,11 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,#ifdef CONFIG_HUGETLB_PAGE static inline int hugepd_ok (hugepd_t hpd) { +#ifdef CONFIG_PPC_8xx +return ((hpd.pd &0x4 ) !=0 ); +#else return (hpd.pd >0 ); +#endif }static inline int pmd_huge (pmd_t pmd)
arch/powerpc/include/asm/reg_8xx.h +1 -1
@@ -4,7 +4,7 @@#ifndef _ASM_POWERPC_REG_8xx_H#define _ASM_POWERPC_REG_8xx_H -#include <asm/mmu-8xx.h> +#include <asm/mmu.h> /* Cache control on the MPC8xx is provided through some additional * special purpose registers.
arch/powerpc/kernel/head_8xx.S +113 -6
219 lines not on this page · raw message
arch/powerpc/mm/hugetlbpage.c +61 -115
343 lines not on this page · raw message
arch/powerpc/mm/tlb_nohash.c +20 -1
@@ -53,7 +53,7 @@* other sizes not listed here. The .ind field is only used on MMUs that have * indirect page table entries. */ -#ifdef CONFIG_PPC_BOOK3E_MMU +#if defined(CONFIG_PPC_BOOK3E_MMU) || defined (CONFIG_PPC_8xx) #ifdef CONFIG_PPC_FSL_BOOK3E struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { [MMU_PAGE_4K] = {
@@ -85,6 +85,25 @@ struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { .enc = BOOK3E_PAGESZ_1GB, }, }; +#elif defined (CONFIG_PPC_8xx) +struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { + /* we only manage 4k and 16k pages as normal pages */ +#ifdef CONFIG_PPC_4K_PAGES + [MMU_PAGE_4K] = { + .shift = 12, + }, +#else + [MMU_PAGE_16K] = { + .shift = 14, + }, +#endif + [MMU_PAGE_512K] = { + .shift = 19, + }, + [MMU_PAGE_8M] = { + .shift = 23, + }, +}; #else struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { [MMU_PAGE_4K] = {
arch/powerpc/platforms/8xx/Kconfig +1 -0
@@ -130,6 +130,7 @@ config 8xx_CPU6 config 8xx_CPU15 bool "CPU15 Silicon Errata" + depends on !HUGETLB_PAGE default y help This enables a workaround for erratum CPU15 on MPC8xx chips.
arch/powerpc/platforms/Kconfig.cputype +1 -0
@@ -34,6 +34,7 @@ config PPC_8xx select FSL_SOC select 8xx select PPC_LIB_RHEAP + select SYS_SUPPORTS_HUGETLBFS config 40x bool "AMCC 40x"
Signature · 1 line
2.1.0
Re: [PATCH 1/6] powerpc: port 64 bits pgtable_cache to 32 bits
In reply to Christophe LeroyQuoted 7 lines · Christophe Leroy
Today powerpc64 uses a set of
pgtable_cacheswhile powerpc32 uses standard pages when using 4k pages and a singlepgtable_cacheif using other size pages. In addition powerpc32 uses another cache when handling huge pages.In preparation of implementing huge pages on the 8xx, this patch replaces the specific powerpc32 handling by the 64 bits approach.
Why is this needed ? Can you also summarize the page size used and the hugepage format you are planning to use ? . What are the page sizes supported by 8xx ? Also is the new code copy of existing powerpc64 4k page size code ?
Quoted 374 lines
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 44 ++++++-- arch/powerpc/include/asm/book3s/32/pgtable.h | 43 ++++---- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 - arch/powerpc/include/asm/hugetlb.h | 2 - arch/powerpc/include/asm/nohash/32/pgalloc.h | 44 ++++++-- arch/powerpc/include/asm/nohash/32/pgtable.h | 45 ++++---- arch/powerpc/include/asm/nohash/64/pgtable.h | 2 - arch/powerpc/include/asm/pgtable.h | 2 + arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/hugetlbpage.c | 12 +-- arch/powerpc/mm/init-common.c | 152 +++++++++++++++++++++++++++ arch/powerpc/mm/init_32.c | 5 - arch/powerpc/mm/init_64.c | 82 --------------- arch/powerpc/mm/pgtable_32.c | 37 ------- 14 files changed, 282 insertions(+), 193 deletions(-) create mode 100644 arch/powerpc/mm/init-common.carch/powerpc/include/asm/book3s/32/pgalloc.h +38
-6@@ -2,14 +2,42 @@#define _ASM_POWERPC_BOOK3S_32_PGALLOC_H#include <linux/threads.h> +#include <linux/slab.h> -/* For 32-bit, all levels of page tables are just drawn from get_free_page() */ -#define MAX_PGTABLE_INDEX_SIZE 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 (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 0xfextern void __bad_pte (pmd_t *pmd); -extern pgd_t *pgd_alloc (struct mm_struct *mm); -extern void pgd_free (struct mm_struct *mm,pgd_t *pgd); +extern struct kmem_cache *pgtable_cache[]; +#define PGT_CACHE (shift) ({ \ + BUG_ON(!(shift)); \ + pgtable_cache[(shift) - 1]; \ + }) + +static inline pgd_t *pgd_alloc (struct mm_struct *mm) +{ +return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),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 @@ -68,8 +96,12 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)static inline void pgtable_free (void *table,unsigned index_size) { -BUG_ON (index_size);/* 32-bit doesn't use this */ -free_page ((unsigned long )table); +if (!index_size) +free_page ((unsigned long )table); +else { +BUG_ON (index_size >MAX_PGTABLE_INDEX_SIZE ); +kmem_cache_free (PGT_CACHE (index_size), table); + } }#define check_pgt_cache () do { } while (0)arch/powerpc/include/asm/book3s/32/pgtable.h +23
-20@@ -8,6 +8,26 @@/* And here we include common definitions */ #include <asm/pte-common.h> +#define PTE_INDEX_SIZE PTE_SHIFT +#define PMD_INDEX_SIZE 0 +#define PUD_INDEX_SIZE 0 +#define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) + +#define PMD_CACHE_INDEX PMD_INDEX_SIZE + +#ifndef __ASSEMBLY__ +#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) +#define PMD_TABLE_SIZE (sizeof(pmd_t) << PTE_INDEX_SIZE) +#define PUD_TABLE_SIZE (sizeof(pud_t) << PTE_INDEX_SIZE) +#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) +#endif /* __ASSEMBLY__ */ + +#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE) +#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE) + +/* With 4k base page size, hugepage PTEs go at the PMD level */ +#define MIN_HUGEPTE_SHIFT PMD_SHIFT +/* * The normal case is that PTEs are 32-bits and we have a 1-page * 1024-entry pgdir pointing to 1-page 1024-entry PTE pages. -- paulus @@ -19,14 +39,10 @@* -Matt */ /* PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT (PAGE_SHIFT + PTE_SHIFT) +#define PGDIR_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)#define PGDIR_SIZE (1UL << PGDIR_SHIFT)#define PGDIR_MASK (~(PGDIR_SIZE-1)) -#define PTRS_PER_PTE (1 << PTE_SHIFT) -#define PTRS_PER_PMD 1 -#define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT)) -#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)/* * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary @@ -82,12 +98,8 @@extern unsigned long ioremap_bot; -/* -* entries per page directory level: our page-table tree is two-level, so -* we don't really have any PMD directory. -*/ -#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_SHIFT) -#define PGD_TABLE_SIZE (sizeof(pgd_t) << (32 - PGDIR_SHIFT)) +/* Bits to mask out from a PGD to get to the PUD page */ +#define PGD_MASKED_BITS 0#define pte_ERROR (e) \ pr_err("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \@@ -282,15 +294,6 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) >> 3 })#define __swp_entry_to_pte (x) ((pte_t) { (x).val << 3 }) -#ifndef CONFIG_PPC_4K_PAGES -void pgtable_cache_init (void ); -#else -/* -* No page table caches to initialise -*/ -#define pgtable_cache_init () do { } while (0) -#endif -extern int get_pteptr (struct mm_struct *mm,unsigned long addr,pte_t **ptep,pmd_t **pmdp);arch/powerpc/include/asm/book3s/64/pgtable.h +0
-3@@ -786,9 +786,6 @@ extern struct page *pgd_page(pgd_t pgd);#define pgd_ERROR (e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); -void pgtable_cache_init (void ); -static inline int map_kernel_page (unsigned long ea,unsigned long pa,unsigned long flags) {arch/powerpc/include/asm/hugetlb.h +0
-2@@ -5,8 +5,6 @@#include <asm/page.h> #include <asm-generic/hugetlb.h> -extern struct kmem_cache *hugepte_cache; -#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/hugetlb-radix.h> arch/powerpc/include/asm/nohash/32/pgalloc.h +38
-6@@ -2,14 +2,42 @@#define _ASM_POWERPC_PGALLOC_32_H#include <linux/threads.h> +#include <linux/slab.h> -/* For 32-bit, all levels of page tables are just drawn from get_free_page() */ -#define MAX_PGTABLE_INDEX_SIZE 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 (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 0xfextern void __bad_pte (pmd_t *pmd); -extern pgd_t *pgd_alloc (struct mm_struct *mm); -extern void pgd_free (struct mm_struct *mm,pgd_t *pgd); +extern struct kmem_cache *pgtable_cache[]; +#define PGT_CACHE (shift) ({ \ + BUG_ON(!(shift)); \ + pgtable_cache[(shift) - 1]; \ + }) + +static inline pgd_t *pgd_alloc (struct mm_struct *mm) +{ +return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),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 @@ -68,8 +96,12 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)static inline void pgtable_free (void *table,unsigned index_size) { -BUG_ON (index_size);/* 32-bit doesn't use this */ -free_page ((unsigned long )table); +if (!index_size) +free_page ((unsigned long )table); +else { +BUG_ON (index_size >MAX_PGTABLE_INDEX_SIZE ); +kmem_cache_free (PGT_CACHE (index_size), table); + } }#define check_pgt_cache () do { } while (0)arch/powerpc/include/asm/nohash/32/pgtable.h +23
-22@@ -16,6 +16,26 @@ extern int icache_44x_need_flush;#endif /* __ASSEMBLY__ */ +#define PTE_INDEX_SIZE PTE_SHIFT +#define PMD_INDEX_SIZE 0 +#define PUD_INDEX_SIZE 0 +#define PGD_INDEX_SIZE (32 - PGDIR_SHIFT) + +#define PMD_CACHE_INDEX PMD_INDEX_SIZE + +#ifndef __ASSEMBLY__ +#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE) +#define PMD_TABLE_SIZE (sizeof(pmd_t) << PTE_INDEX_SIZE) +#define PUD_TABLE_SIZE (sizeof(pud_t) << PTE_INDEX_SIZE) +#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) +#endif /* __ASSEMBLY__ */ + +#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE) +#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE) + +/* With 4k base page size, hugepage PTEs go at the PMD level */ +#define MIN_HUGEPTE_SHIFT PMD_SHIFT +/* * The normal case is that PTEs are 32-bits and we have a 1-page * 1024-entry pgdir pointing to 1-page 1024-entry PTE pages. -- paulus @@ -27,22 +47,12 @@ extern int icache_44x_need_flush;* -Matt */ /* PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT (PAGE_SHIFT + PTE_SHIFT) +#define PGDIR_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)#define PGDIR_SIZE (1UL << PGDIR_SHIFT)#define PGDIR_MASK (~(PGDIR_SIZE-1)) -/* -* entries per page directory level: our page-table tree is two-level, so -* we don't really have any PMD directory. -*/ -#ifndef __ASSEMBLY__ -#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_SHIFT) -#define PGD_TABLE_SIZE (sizeof(pgd_t) << (32 - PGDIR_SHIFT)) -#endif /* __ASSEMBLY__ */ - -#define PTRS_PER_PTE (1 << PTE_SHIFT) -#define PTRS_PER_PMD 1 -#define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT)) +/* Bits to mask out from a PGD to get to the PUD page */ +#define PGD_MASKED_BITS 0#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)#define FIRST_USER_ADDRESS 0UL@@ -327,15 +337,6 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) >> 3 })#define __swp_entry_to_pte (x) ((pte_t) { (x).val << 3 }) -#ifndef CONFIG_PPC_4K_PAGES -void pgtable_cache_init (void ); -#else -/* -* No page table caches to initialise -*/ -#define pgtable_cache_init () do { } while (0) -#endif -extern int get_pteptr (struct mm_struct *mm,unsigned long addr,pte_t **ptep,pmd_t **pmdp);arch/powerpc/include/asm/nohash/64/pgtable.h +0
-2@@ -357,8 +357,6 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val((pte)) })#define __swp_entry_to_pte (x) __pte((x).val) -void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); -void pgtable_cache_init (void );extern int map_kernel_page (unsigned long ea,unsigned long pa,unsigned long flags); extern int __meminit vmemmap_create_mapping(unsigned long start,arch/powerpc/include/asm/pgtable.h +2
-0@@ -78,6 +78,8 @@ static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,unsigned long vmalloc_to_phys (void *vmalloc_addr); +void pgtable_cache_add (unsigned shift,void (*ctor)(void *)); +void pgtable_cache_init (void );#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ arch/powerpc/mm/Makefile +1
-1@@ -7,7 +7,7 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) obj-y := fault.o mem.o pgtable.o mmap.o \ - init_$(CONFIG_WORD_SIZE).o \ + init_$(CONFIG_WORD_SIZE).o init-common.o \ pgtable_$(CONFIG_WORD_SIZE).o obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ tlb_nohash_low.oarch/powerpc/mm/hugetlbpage.c +0
-0
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 74
Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +1
-1@@ -68,7 +68,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,#ifdef CONFIG_PPC_FSL_BOOK3E int i;int num_hugepd =1 << (pshift - pdshift); - cachep = hugepte_cache; + cachep =PGT_CACHE (1 );#else cachep =PGT_CACHE (pdshift - pshift);#endif
Can you explain the usage of PGT_CACHE(1) ?
Quoted 355 lines
arch/powerpc/mm/hugetlbpage.c +4
-6@@ -411,7 +411,7 @@ static void hugepd_free_rcu_callback(struct rcu_head *head)unsigned int i;for (i =0 ; i < batch->index; i++) -kmem_cache_free (hugepte_cache, batch->ptes[i]); +kmem_cache_free (PGT_CACHE (1 ), batch->ptes[i]);free_page ((unsigned long )batch); }@@ -425,7 +425,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte)if (atomic_read (&tlb->mm->mm_users) <2 ||cpumask_equal (mm_cpumask (tlb->mm),cpumask_of (smp_processor_id ()))) { -kmem_cache_free (hugepte_cache, hugepte); +kmem_cache_free (PGT_CACHE (1 ), hugepte);put_cpu_var (hugepd_freelist_cur);return ; }@@ -792,7 +792,6 @@ static int __init hugepage_setup_sz(char *str)__setup ("hugepagesz=" , hugepage_setup_sz);#ifdef CONFIG_PPC_FSL_BOOK3E -struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ) {int psize;@@ -815,9 +814,8 @@ static int __init hugetlbpage_init(void)* Create a kmem cache for hugeptes. The bottom bits in the pte have * size information encoded in them, so align them to allow this */ - hugepte_cache =kmem_cache_create ("hugepte-cache" ,sizeof (pte_t), -HUGEPD_SHIFT_MASK +1 ,0 ,NULL ); -if (hugepte_cache ==NULL ) +pgtable_cache_add (1 ,NULL ); +if (!PGT_CACHE (1 ))panic ("%s: Unable to create kmem cache for hugeptes\n" , __func__);arch/powerpc/mm/init-common.c new file +152
-0@@ -0,0 +1,152 @@ +/* +* PowerPC version +* Copyright (C) 1995-1996 Gary Thomas ([email protected]) +* +* Modifications by Paul Mackerras (PowerMac) ([email protected]) +* and Cort Dougan (PReP) ([email protected]) +* Copyright (C) 1996 Paul Mackerras +* +* Derived from "arch/i386/mm/init.c" +* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds +* +* Dave Engebretsen <[email protected]> +* Rework for PPC64 port. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +*/ + +#undef DEBUG + +#include <linux/signal.h> +#include <linux/sched.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/types.h> +#include <linux/mman.h> +#include <linux/mm.h> +#include <linux/swap.h> +#include <linux/stddef.h> +#include <linux/vmalloc.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/highmem.h> +#include <linux/idr.h> +#include <linux/nodemask.h> +#include <linux/module.h> +#include <linux/poison.h> +#include <linux/memblock.h> +#include <linux/hugetlb.h> +#include <linux/slab.h> + +#include <asm/pgalloc.h> +#include <asm/page.h> +#include <asm/prom.h> +#include <asm/rtas.h> +#include <asm/io.h> +#include <asm/mmu_context.h> +#include <asm/pgtable.h> +#include <asm/mmu.h> +#include <asm/uaccess.h> +#include <asm/smp.h> +#include <asm/machdep.h> +#include <asm/tlb.h> +#include <asm/eeh.h> +#include <asm/processor.h> +#include <asm/mmzone.h> +#include <asm/cputable.h> +#include <asm/sections.h> +#include <asm/iommu.h> +#include <asm/vdso.h> + +#include "mmu_decl.h" + +phys_addr_t memstart_addr = (phys_addr_t )~0ull ; +EXPORT_SYMBOL_GPL (memstart_addr); +phys_addr_t kernstart_addr; +EXPORT_SYMBOL_GPL (kernstart_addr); + +static void pgd_ctor (void *addr) +{ +memset (addr,0 ,PGD_TABLE_SIZE ); +} + +static void pud_ctor (void *addr) +{ +memset (addr,0 ,PUD_TABLE_SIZE ); +} + +static void pmd_ctor (void *addr) +{ +memset (addr,0 ,PMD_TABLE_SIZE ); +} + +struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE ]; + +/* +* Create a kmem_cache() for pagetables. This is not used for PTE +* pages - they're linked to struct page, come from the normal free +* pages pool and have a different entry size (see real_pte_t) to +* everything else. Caches created by this function are used for all +* the higher level pagetables, and for hugepage pagetables. +*/ +void pgtable_cache_add (unsigned shift,void (*ctor)(void *)) +{ +char *name; +unsigned long table_size =sizeof (void *) << shift; +unsigned long align = table_size; + +/* When batching pgtable pointers for RCU freeing, we store +* the index size in the low bits. Table alignment must be +* big enough to fit it. +* +* Likewise, hugeapge pagetable pointers contain a (different) +* shift value in the low bits. All tables must be aligned so +* as to leave enough 0 bits in the address to contain it. */ +unsigned long minalign =max (MAX_PGTABLE_INDEX_SIZE +1 , +HUGEPD_SHIFT_MASK +1 ); +struct kmem_cache *new; + +/* It would be nice if this was a BUILD_BUG_ON(), but at the +* 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 )); + +if (PGT_CACHE (shift)) +return ;/* Already have a cache of this size */ + + align = max_t(unsigned long, align, minalign); + name =kasprintf (GFP_KERNEL ,"pgtable-2^%d" , shift); + new =kmem_cache_create (name, table_size, align,0 , ctor); +kfree (name); + pgtable_cache[shift -1 ] = new; +pr_debug ("Allocated pgtable cache for order %d\n" , shift); +} + + +void pgtable_cache_init (void ) +{ +pgtable_cache_add (PGD_INDEX_SIZE , pgd_ctor); + +if (PMD_INDEX_SIZE && !PGT_CACHE (PMD_INDEX_SIZE )) +pgtable_cache_add (PMD_CACHE_INDEX , pmd_ctor); +/* +* In all current configs, when the PUD index exists it's the +* same size as either the pgd or pmd index except with THP enabled +* on book3s 64 +*/ +if (PUD_INDEX_SIZE && !PGT_CACHE (PUD_INDEX_SIZE )) +pgtable_cache_add (PUD_INDEX_SIZE , pud_ctor); + +if (!PGT_CACHE (PGD_INDEX_SIZE )) +panic ("Couldn't allocate pgd cache" ); +if (PMD_INDEX_SIZE && !PGT_CACHE (PMD_INDEX_SIZE )) +panic ("Couldn't allocate pmd pgtable caches" ); +if (PUD_INDEX_SIZE && !PGT_CACHE (PUD_INDEX_SIZE )) +panic ("Couldn't allocate pud pgtable caches" ); +}arch/powerpc/mm/init_32.c +0
-5@@ -59,11 +59,6 @@phys_addr_t total_memory;phys_addr_t total_lowmem; -phys_addr_t memstart_addr = (phys_addr_t )~0ull ; -EXPORT_SYMBOL (memstart_addr); -phys_addr_t kernstart_addr; -EXPORT_SYMBOL (kernstart_addr); -#ifdef CONFIG_RELOCATABLE /* Used in __va()/__pa() */ long long virt_phys_offset;arch/powerpc/mm/init_64.c +0
-82@@ -75,88 +75,6 @@#endif #endif /* CONFIG_PPC_STD_MMU_64 */ -phys_addr_t memstart_addr = ~0 ; -EXPORT_SYMBOL_GPL (memstart_addr); -phys_addr_t kernstart_addr; -EXPORT_SYMBOL_GPL (kernstart_addr); - -static void pgd_ctor (void *addr) -{ -memset (addr,0 ,PGD_TABLE_SIZE ); -} - -static void pud_ctor (void *addr) -{ -memset (addr,0 ,PUD_TABLE_SIZE ); -} - -static void pmd_ctor (void *addr) -{ -memset (addr,0 ,PMD_TABLE_SIZE ); -} - -struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE ]; - -/* -* Create a kmem_cache() for pagetables. This is not used for PTE -* pages - they're linked to struct page, come from the normal free -* pages pool and have a different entry size (see real_pte_t) to -* everything else. Caches created by this function are used for all -* the higher level pagetables, and for hugepage pagetables. -*/ -void pgtable_cache_add (unsigned shift,void (*ctor)(void *)) -{ -char *name; -unsigned long table_size =sizeof (void *) << shift; -unsigned long align = table_size; - -/* When batching pgtable pointers for RCU freeing, we store -* the index size in the low bits. Table alignment must be -* big enough to fit it. -* -* Likewise, hugeapge pagetable pointers contain a (different) -* shift value in the low bits. All tables must be aligned so -* as to leave enough 0 bits in the address to contain it. */ -unsigned long minalign =max (MAX_PGTABLE_INDEX_SIZE +1 , -HUGEPD_SHIFT_MASK +1 ); -struct kmem_cache *new; - -/* It would be nice if this was a BUILD_BUG_ON(), but at the -* 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 )); - -if (PGT_CACHE (shift)) -return ;/* Already have a cache of this size */ - - align = max_t(unsigned long, align, minalign); - name =kasprintf (GFP_KERNEL ,"pgtable-2^%d" , shift); - new =kmem_cache_create (name, table_size, align,0 , ctor); -kfree (name); - pgtable_cache[shift -1 ] = new; -pr_debug ("Allocated pgtable cache for order %d\n" , shift); -} - - -void pgtable_cache_init (void ) -{ -pgtable_cache_add (PGD_INDEX_SIZE , pgd_ctor); -pgtable_cache_add (PMD_CACHE_INDEX , pmd_ctor); -/* -* In all current configs, when the PUD index exists it's the -* same size as either the pgd or pmd index except with THP enabled -* on book3s 64 -*/ -if (PUD_INDEX_SIZE && !PGT_CACHE (PUD_INDEX_SIZE )) -pgtable_cache_add (PUD_INDEX_SIZE , pud_ctor); - -if (!PGT_CACHE (PGD_INDEX_SIZE ) || !PGT_CACHE (PMD_CACHE_INDEX )) -panic ("Couldn't allocate pgtable caches" ); -if (PUD_INDEX_SIZE && !PGT_CACHE (PUD_INDEX_SIZE )) -panic ("Couldn't allocate pud pgtable caches" ); -} -#ifdef CONFIG_SPARSEMEM_VMEMMAP /* * Given an address within the vmemmap, determine the pfn of the page that arch/powerpc/mm/pgtable_32.c +0
-37@@ -42,43 +42,6 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */extern char etext[], _stext[], _sinittext[], _einittext[]; -#define PGDIR_ORDER (32 + PGD_T_LOG2 - PGDIR_SHIFT) - -#ifndef CONFIG_PPC_4K_PAGES -static struct kmem_cache *pgtable_cache; - -void pgtable_cache_init (void ) -{ - pgtable_cache =kmem_cache_create ("PGDIR cache" ,1 <<PGDIR_ORDER , -1 <<PGDIR_ORDER ,0 ,NULL ); -if (pgtable_cache ==NULL ) -panic ("Couldn't allocate pgtable caches" ); -} -#endif - -pgd_t *pgd_alloc (struct mm_struct *mm) -{ -pgd_t *ret; - -/* pgdir take page or two with 4K pages and a page fraction otherwise */ -#ifndef CONFIG_PPC_4K_PAGES - ret =kmem_cache_alloc (pgtable_cache,GFP_KERNEL | __GFP_ZERO); -#else - ret = (pgd_t *)__get_free_pages (GFP_KERNEL |__GFP_ZERO, -PGDIR_ORDER -PAGE_SHIFT ); -#endif -return ret; -} - -void pgd_free (struct mm_struct *mm,pgd_t *pgd) -{ -#ifndef CONFIG_PPC_4K_PAGES -kmem_cache_free (pgtable_cache, (void *)pgd); -#else -free_pages ((unsigned long )pgd,PGDIR_ORDER -PAGE_SHIFT ); -#endif -} -__ref pte_t *pte_alloc_one_kernel (struct mm_struct *mm,unsigned long address) {pte_t *pte;Signature · 1 line
2.1.0
I still didn't quiet follow why we are replacing
- hugepte_cache = kmem_cache_create("hugepte-cache", sizeof(pte_t),
- HUGEPD_SHIFT_MASK + 1, 0, NULL);
+ pgtable_cache_add(1, NULL);
-aneesh
Quoted 10 lines · Christophe Leroy
The 8xx has 512k and 8M pages. This patch implements hugepages using those sizes.
On the 8xx, the size of pages is in the PGD entry, using PS field (bits 28-29):
00 : Small pages (4k or 16k)
01 : 512k pages
10 : reserved
11 : 8M pages
Quoted 6 lines
The implementation uses a mix of what is used on BOOKS and BOOKE, as 512k pages are in HUGEPTE tables while for 8M pages we have several PGD entries pointing on a leaf HUGEPTE entry
For the time being, we do not support CPU15 ERRATA if HUGETLB is selected
Can you also document here the format for linux page table with different huge page size. ?
Quoted 2 lines
Signed-off-by Christophe Leroy <[email protected]>
Quoted 9 lines · Christophe Leroy
This set provides implementation of huge pages on the 8xx
Christophe Leroy (6):
powerpc: port 64 bitspgtable_cacheto 32 bits
powerpc: fix usage of_PAGE_ROin hugepage
powerpc/8xx: use r3 to scratch CR in ITLBmiss powerpc/8xx: Move additional DTLBMiss handlers out of exception area powerpc/8xx: make user addr DTLB miss the short path powerpc/8xx: implementation of huge pages
Patch 2,3,4,5 are not really related to hugepage implementation right ? May be that can be sent as a separate series ?
-aneesh
Quoted 12 lines · Aneesh Kumar K.V
Quoted 9 lines · Christophe Leroy
This set provides implementation of huge pages on the 8xx
Christophe Leroy (6):
powerpc: port 64 bitspgtable_cacheto 32 bits
powerpc: fix usage of_PAGE_ROin hugepage
powerpc/8xx: use r3 to scratch CR in ITLBmiss powerpc/8xx: Move additional DTLBMiss handlers out of exception area powerpc/8xx: make user addr DTLB miss the short path powerpc/8xx: implementation of huge pages
Quoted 3 lines
Patch 2,3,4,5 are not really related to hugepage implementation right ? May be that can be sent as a separate series ?
Patch 2 is a lack in gup_hugepte: on 8xx, _PAGE_RW (hence _PAGE_WRITE) is defined as 0 and _PAGE_RO must be set when the page in not writeable. So that's a prerequisite to implementation of huge page
Patch 3, 4, 5 are prerequisits for the implementation of huge page handling in the TLB miss handlers:
* 3: for huge pages implementation we need to branch base of value of bit 28 and 29 of the PGD entry. For this we need to preserve CR.
* 4: With the instructions related to hugepages, there is not enough space anymore in the TLB Exception areas, so part of the it has to be moved away.
* 5: That one might be seen as not directly related to hugepages, but it requires patch 3.
Maybe I should reorder into 3, 4, 5, 2, 1, 6 ?
Christophe
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
Quoted 16 lines · Aneesh Kumar K.V
Quoted 14 lines · Christophe Leroy
The 8xx has 512k and 8M pages. This patch implements hugepages using those sizes.
On the 8xx, the size of pages is in the PGD entry, using PS field (bits 28-29):
00 : Small pages (4k or 16k)
01 : 512k pages
10 : reserved
11 : 8M pagesThe implementation uses a mix of what is used on BOOKS and BOOKE, as 512k pages are in HUGEPTE tables while for 8M pages we have several PGD entries pointing on a leaf HUGEPTE entry
Quoted 5 lines
Quoted 2 lines
For the time being, we do not support CPU15 ERRATA if HUGETLB is selected
Can you also document here the format for linux page table with different huge page size. ?
Euh ... isn't it what I do when explaining the use of the PS field in the PGD entry ? That's the thing, that's how the 8xx knows how it is a huge page, and that's how Linux will know it is one. On the 8xx, the Linux PGD entry (almost) match the L1 MMU entry and the Linux PTE almost match the L2 MMU entry (some bits are copied from the PTE to the L1 entry and then removed from the value writen to the L2 MMU entry)
Christophe
Quoted 3 lines
Quoted 3 lines
Signed-off-by Christophe Leroy <[email protected]>
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
Re: [PATCH 1/6] powerpc: port 64 bits pgtable_cache to 32 bits
In reply to Aneesh Kumar K.VQuoted 7 lines · Aneesh Kumar K.V
Quoted 5 lines · Christophe Leroy
Today powerpc64 uses a set of
pgtable_cacheswhile powerpc32 uses standard pages when using 4k pages and a singlepgtable_cacheif using other size pages. In addition powerpc32 uses another cache when handling huge pages.
Quoted 7 lines
Quoted 2 lines
In preparation of implementing huge pages on the 8xx, this patch replaces the specific powerpc32 handling by the 64 bits approach.
Why is this needed ? Can you also summarize the page size used and the hugepage format you are planning to use ? . What are the page sizes supported by 8xx ? Also is the new code copy of existing powerpc64 4k page size code ?
8xx supports two huge page sizes: 8M and 512k.
As PGD entries points on 4M page tables, it means we are in an eterogenous situation:
1/ when using 8M huge pages, we are in the same situation as what is done for the BOOK3S (which supports 16M, 256M and 1G), that is several PDG entries pointing to a single PTE entry. 2/ when using 512k huge pages, we are in the same situation as whan is done for the BOOK3E: a PGD entry points to the hugepage table that handles several huge pages (in our case 8 huge pages)
The code from init_64 have been moved to a new file named init-common in order to be used by init_32 too.
The code from the 64 bits .h has been copied into the 32 bits .h (indeed it's been copied twice as the .h are now duplicated into nohash and book3s versions)
[...]
Quoted 15 lines
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 74
Quoted 13 lines
arch/powerpc/mm/hugetlbpage.c +1
-1@@ -68,7 +68,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,#ifdef CONFIG_PPC_FSL_BOOK3E int i;int num_hugepd =1 << (pshift - pdshift); - cachep = hugepte_cache; + cachep =PGT_CACHE (1 );#else cachep =PGT_CACHE (pdshift - pshift);#endif Can you explain the usage of
PGT_CACHE(1)?
[...]
Quoted 7 lines
I still didn't quiet follow why we are replacing
-
hugepte_cache= kmem_cache_create("hugepte-cache",sizeof(pte_t),
-HUGEPD_SHIFT_MASK+ 1, 0, NULL);
+pgtable_cache_add(1, NULL);
Euh ... Indeed I wanted something to replace hugepte_cache. But it looks like it should be something like PGT_CACHE(0) for 32 bits targets having 32 bits PTEs and PGT_CACHE(1) for 32 bits targets having 64 bits PTEs. But PGT_CACHE(0) doesn't exist (yet).
Looking once more, that might not really be needed I think. I'll rework it and see what I can achieve.
Christophe
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
Re: [PATCH 1/6] powerpc: port 64 bits pgtable_cache to 32 bits
Quoted 16 lines · christophe leroy
Le 14/08/2016 =C3=A0 16:17, Aneesh Kumar K.V a =C3=A9crit :
Quoted 7 lines
Quoted 5 lines · Christophe Leroy
Today powerpc64 uses a set of
pgtable_cacheswhile powerpc32 uses standard pages when using 4k pages and a singlepgtable_cacheif using other size pages. In addition powerpc32 uses another cache when handling huge pages.Quoted 7 lines
Quoted 2 lines
In preparation of implementing huge pages on the 8xx, this patch replaces the specific powerpc32 handling by the 64 bits approach.
Why is this needed ? Can you also summarize the page size used and the hugepage format you are planning to use ? . What are the page sizes supported by 8xx ? Also is the new code copy of existing powerpc64 4k page size code ?
Quoted 6 lines
8xx supports two huge page sizes: 8M and 512k.
As PGD entries points on 4M page tables, it means we are in an=20 eterogenous situation:
1/ when using 8M huge pages, we are in the same situation as what is=20 done for the BOOK3S (which supports 16M, 256M and 1G), that is several=20 PDG entries pointing to a single PTE entry.
what is done for FSL BOOK3E ?
Quoted 4 lines
2/ when using 512k huge pages, we are in the same situation as whan is=20 done for the BOOK3E: a PGD entry points to the hugepage table that=20 handles several huge pages (in our case 8 huge pages)
what is done for Book3s with 4K linux page size. ?
So the idea here is to allocate different hugepte table based on hugepage size requested and hence the need to switch from hugpte-cache to a more generic PGT_CACHE ?
Quoted 1 line
The code from
init_64have been moved to a new file named init-common in=
=20
Quoted 2 lines
order to be used by
init_32too.
The code from the 64 bits .h has been copied into the 32 bits .h (indeed=
=20
Quoted 2 lines
it's been copied twice as the .h are now duplicated into nohash and=20 book3s versions)
That explanation made it a lot easy to follow the patch. Can we capture that in commit message too. Also Do we support hugepage with both 4k and 16K linux page size ?. I guess we do because 8xx only do a two level linux page table ?=20
Quoted 4 lines
[...]
Quoted 1 line
arch/powerpc/mm/hugetlbpag=
Quoted 1 line
arch/powerpc/mm/hugetlbpag= renamed from arch/powerpc/mm/hugetlbpage.c +0
-0
e.c
Quoted 4 lines
Quoted 4 lines
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, huge=
Quoted 4 lines
index 7372ee1..9164a77 100644
arch/powerpc/mm/hugetlbpage.c +0
-0@@ -68,7 +68,7 @@ static int __hugepte_alloc(struct mm_struct *mm, huge=
pd_t *hpdp,
Quoted 14 lines
Quoted 10 lines
arch/powerpc/mm/hugetlbpage.c static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, · line 74
Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c +1
-1#ifdef CONFIG_PPC_FSL_BOOK3E int i; int num_hugepd =3D 1 << (pshift - pdshift); - cachep =3D hugepte_cache; + cachep =3D PGT_CACHE(1);#else cachep =3D PGT_CACHE(pdshift - pshift);#endif Can you explain the usage of
PGT_CACHE(1)?[...]
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
I still didn't quiet follow why we are replacing
-
hugepte_cache=3D kmem_cache_create("hugepte-cache",sizeof(pte_t),
-HUGEPD_SHIFT_MASK+ 1, 0, NULL);
+pgtable_cache_add(1, NULL);Euh ... Indeed I wanted something to replace
hugepte_cache. But it looks=
=20
Quoted 1 line
like it should be something like
PGT_CACHE(0)for 32 bits targets having=
=20
Quoted 6 lines
32 bits PTEs and
PGT_CACHE(1)for 32 bits targets having 64 bits PTEs.=20 ButPGT_CACHE(0)doesn't exist (yet).Looking once more, that might not really be needed I think. I'll rework=20 it and see what I can achieve.
Thanks
-aneesh
Quoted 20 lines · christophe leroy
Le 14/08/2016 =C3=A0 16:25, Aneesh Kumar K.V a =C3=A9crit :
Quoted 19 lines
Quoted 16 lines · Christophe Leroy
The 8xx has 512k and 8M pages. This patch implements hugepages using those sizes.
On the 8xx, the size of pages is in the PGD entry, using PS field (bits 28-29):
00 : Small pages (4k or 16k)
01 : 512k pages
10 : reserved
11 : 8M pagesThe implementation uses a mix of what is used on BOOKS and BOOKE, as 512k pages are in HUGEPTE tables while for 8M pages we have several PGD entries pointing on a leaf HUGEPTE entry
For the time being, we do not support CPU15 ERRATA if HUGETLB is selected
Quoted 7 lines
Quoted 2 lines
Can you also document here the format for linux page table with different huge page size. ?
Euh ... isn't it what I do when explaining the use of the PS field in=20 the PGD entry ? That's the thing, that's how the 8xx knows how it is a=20 huge page, and that's how Linux will know it is one. On the 8xx, the=20 Linux PGD entry (almost) match the L1 MMU entry and the Linux PTE almost=
=20
Quoted 3 lines
match the L2 MMU entry (some bits are copied from the PTE to the L1=20 entry and then removed from the value writen to the L2 MMU entry)
Sorry if that answer was obvious in the commit message. I haven't looked at 8xx pagetable format closely to understand the details. Now with your reply to the earlier email, I looked at the changes again and wonder whether we can document details like.
8xx uses a two level page table with two different linux page size support (4k and 16k). 8xx also support two different hugepage sizes 512k and 8M. Inorder to support then on linux we define two different page table layout.
For 512K hugepage size a pgd entry have the below format [<hugepte address >0100] . The hugepte table allocated will contain <x> entries pointing to 512K huge pte.
For 8M multiple pgd entries point to the same hugepte address. and pgd entry will have the below format
[<hugepte address>1100]. The hugepte table allocated will only have one entry.
I agree that this is the same details you explained in the commit messages. But calling out all details will help anybody reading the code later.
-aneesh
Quoted 31 lines · christophe leroy
Quoted 12 lines · Aneesh Kumar K.V
Quoted 9 lines · Christophe Leroy
This set provides implementation of huge pages on the 8xx
Christophe Leroy (6):
powerpc: port 64 bitspgtable_cacheto 32 bits
powerpc: fix usage of_PAGE_ROin hugepage
powerpc/8xx: use r3 to scratch CR in ITLBmiss powerpc/8xx: Move additional DTLBMiss handlers out of exception area powerpc/8xx: make user addr DTLB miss the short path powerpc/8xx: implementation of huge pagesQuoted 3 lines
Patch 2,3,4,5 are not really related to hugepage implementation right ? May be that can be sent as a separate series ?
Patch 2 is a lack in
gup_hugepte: on 8xx,_PAGE_RW(hence_PAGE_WRITE) is defined as 0 and_PAGE_ROmust be set when the page in not writeable. So that's a prerequisite to implementation of huge pagePatch 3, 4, 5 are prerequisits for the implementation of huge page handling in the TLB miss handlers:
* 3: for huge pages implementation we need to branch base of value of bit 28 and 29 of the PGD entry. For this we need to preserve CR.
* 4: With the instructions related to hugepages, there is not enough space anymore in the TLB Exception areas, so part of the it has to be moved away.
* 5: That one might be seen as not directly related to hugepages, but it requires patch 3.
Quoted 2 lines
Maybe I should reorder into 3, 4, 5, 2, 1, 6 ?
Can't 3,4,5,2 be merged independent of the series ? Reading then suggested they are either fixes or performance improvements ?
-aneesh