PowerISA 3.0 Radix page table support
Subsystems (9)
Re: [PATCH V2 52/68] powerpc/mm: make 4k and 64k use pte_t for pgtable_t
In reply to Aneesh Kumar K.VQuoted 2 lines · Aneesh Kumar K.V
pgtable_page_dtorfor nohash is now moved topte_fragment_free_mm()
This patch switch 4K linux page size config to use pte_t * type instead of struct page * for pgtable_t. This simplifies the code a lot helps in consolidating both 64k and 4k page allocator routines. The changes should not have any impact, because we already store physical address in the upper level page table tree and that implies we already do struct page * to physical address conversion.
One change to note here is we move the pgtable_page_dtor call for nohash to pte_fragment_free_mm(). The nohash related change is due to the related changes in pgtable_64.c.
Quoted 316 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/include/asm/book3s/64/pgalloc.h | 147 +++++++-------------------- arch/powerpc/include/asm/nohash/64/pgalloc.h | 38 +------ arch/powerpc/include/asm/page.h | 10 +- arch/powerpc/mm/pgtable_64.c | 2 +- 4 files changed, 52 insertions(+), 145 deletions(-)arch/powerpc/include/asm/book3s/64/pgalloc.h +39
-108@@ -41,6 +41,15 @@ extern struct kmem_cache *pgtable_cache[]; pgtable_cache[(shift) -1 ]; \ }) +#define PGALLOC_GFP GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO + +extern pte_t *pte_fragment_alloc (struct mm_struct *,unsigned long ,int ); +extern void pte_fragment_free (unsigned long *,int ); +extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift); +#ifdef CONFIG_SMP +extern void __tlb_remove_table (void *_table); +#endif +static inline pgd_t *pgd_alloc (struct mm_struct *mm) {return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),GFP_KERNEL );@@ -72,29 +81,47 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)pud_set (pud,__pgtable_ptr_val (pmd)); } +static inline void __pud_free_tlb (struct mmu_gather *tlb,pud_t *pud, +unsigned long address) +{ +pgtable_free_tlb (tlb, pud,PUD_INDEX_SIZE ); +} + +static inline pmd_t *pmd_alloc_one (struct mm_struct *mm,unsigned long addr) +{ +return kmem_cache_alloc (PGT_CACHE (PMD_CACHE_INDEX ), +GFP_KERNEL |__GFP_REPEAT); +} + +static inline void pmd_free (struct mm_struct *mm,pmd_t *pmd) +{ +kmem_cache_free (PGT_CACHE (PMD_CACHE_INDEX ), pmd); +} + +static inline void __pmd_free_tlb (struct mmu_gather *tlb,pmd_t *pmd, +unsigned long address) +{ +return pgtable_free_tlb (tlb, pmd,PMD_CACHE_INDEX ); +} +static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) {pmd_set (pmd,__pgtable_ptr_val (pte)); } -/* -* FIXME!! -* Between 4K and 64K pages, we differ in what is stored in pmd. ie. -* typedef pte_t *pgtable_t; -> 64K -* typedef struct page *pgtable_t; -> 4k -*/ -#ifdef CONFIG_PPC_4K_PAGES +static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd,pgtable_t pte_page) { -pmd_set (pmd,__pgtable_ptr_val (page_address (pte_page))); +pmd_set (pmd,__pgtable_ptr_val (pte_page)); }static inline pgtable_t pmd_pgtable (pmd_t pmd) { -return pmd_page (pmd); +return (pgtable_t )pmd_page_vaddr (pmd); } +#ifdef CONFIG_PPC_4K_PAGES static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm,unsigned long address) {@@ -115,83 +142,10 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,__free_page (page); return NULL; } -return page; -} - -static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) -{ -free_page ((unsigned long )pte); -} - -static inline void pte_free (struct mm_struct *mm,pgtable_t ptepage) -{ -pgtable_page_dtor (ptepage); -__free_page (ptepage); -} - -static inline void pgtable_free (void *table,unsigned index_size) -{ -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); - } -} - -#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 /* !CONFIG_SMP */ -static inline void pgtable_free_tlb (struct mmu_gather *tlb, -void *table,int shift) -{ -pgtable_free (table, shift); -} -#endif /* CONFIG_SMP */ - -static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table, -unsigned long address) -{ -tlb_flush_pgtable (tlb, address); -pgtable_page_dtor (table); -pgtable_free_tlb (tlb,page_address (table),0 ); +return pte; } -#else /* if CONFIG_PPC_64K_PAGES */ -extern pte_t *pte_fragment_alloc (struct mm_struct *,unsigned long ,int ); -extern void pte_fragment_free (unsigned long *,int ); -extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift); -#ifdef CONFIG_SMP -extern void __tlb_remove_table (void *_table); -#endif - -static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd, -pgtable_t pte_page) -{ -pmd_set (pmd,__pgtable_ptr_val (pte_page)); -} - -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,unsigned long address) {@@ -199,10 +153,11 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, }static inline pgtable_t pte_alloc_one (struct mm_struct *mm, -unsigned long address) +unsigned long address) {return (pgtable_t )pte_fragment_alloc (mm, address,0 ); } +#endif static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) {@@ -220,30 +175,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,tlb_flush_pgtable (tlb, address);pgtable_free_tlb (tlb, table,0 ); } -#endif /* CONFIG_PPC_4K_PAGES */ - -static inline pmd_t *pmd_alloc_one (struct mm_struct *mm,unsigned long addr) -{ -return kmem_cache_alloc (PGT_CACHE (PMD_CACHE_INDEX ), -GFP_KERNEL |__GFP_REPEAT); -} - -static inline void pmd_free (struct mm_struct *mm,pmd_t *pmd) -{ -kmem_cache_free (PGT_CACHE (PMD_CACHE_INDEX ), pmd); -} - -static inline void __pmd_free_tlb (struct mmu_gather *tlb,pmd_t *pmd, -unsigned long address) -{ -return pgtable_free_tlb (tlb, pmd,PMD_CACHE_INDEX ); -} - -static inline void __pud_free_tlb (struct mmu_gather *tlb,pud_t *pud, -unsigned long address) -{ -pgtable_free_tlb (tlb, pud,PUD_INDEX_SIZE ); -}#define check_pgt_cache () do { } while (0)arch/powerpc/include/asm/nohash/64/pgalloc.h +3
-35@@ -119,46 +119,14 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)__free_page (ptepage); } -static inline void pgtable_free (void *table,unsigned index_size) -{ -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); - } -} - +extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift);#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 /* !CONFIG_SMP */ -static inline void pgtable_free_tlb (struct mmu_gather *tlb, -void *table,int shift) -{ -pgtable_free (table, shift); -} -#endif /* CONFIG_SMP */ - +extern void __tlb_remove_table (void *_table); +#endif static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) {tlb_flush_pgtable (tlb, address); -pgtable_page_dtor (table);pgtable_free_tlb (tlb,page_address (table),0 ); }arch/powerpc/include/asm/page.h +9
-1@@ -316,12 +316,20 @@ void arch_free_page(struct page *page, int order);#endif struct vm_area_struct ; - +#ifdef CONFIG_PPC_BOOK3S_64 +/* +* 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 ; +#else #if defined(CONFIG_PPC_64K_PAGES ) && defined(CONFIG_PPC64 )typedef pte_t *pgtable_t ;#else typedef struct page *pgtable_t ;#endif +#endif #include <asm-generic/memory_model.h> #endif /* __ASSEMBLY__ */ arch/powerpc/mm/pgtable_64.c +1
-1@@ -367,6 +367,7 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel return __alloc_for_cache(mm, kernel); } +#endif /* CONFIG_PPC_64K_PAGES */ void pte_fragment_free (unsigned long *table,int kernel) {@@ -413,7 +414,6 @@ void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift) } }#endif -#endif /* CONFIG_PPC_64K_PAGES */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE Signature · 1 line
2.5.0
PATCH v2 53/68 powerpc/mm: Add radix pgalloc details
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/pgalloc.h | 34 ++++++++++++++++++++++++---- arch/powerpc/include/asm/book3s/64/pgtable.h | 10 ++++++-- arch/powerpc/mm/hash_utils_64.c | 7 ++++++ arch/powerpc/mm/pgtable-radix.c | 5 +++- arch/powerpc/mm/pgtable_64.c | 6 +++++ 5 files changed, 55 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/book3s/64/pgalloc.h +30 -4
@@ -50,19 +50,45 @@ extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift);extern void __tlb_remove_table (void *_table);#endif +static inline pgd_t *rpgd_alloc (struct mm_struct *mm) +{ +#ifdef CONFIG_PPC_64K_PAGES +return (pgd_t *)__get_free_page (PGALLOC_GFP ); +#else +struct page *page; + page =alloc_pages (PGALLOC_GFP ,4 ); +if (!page) +return NULL ; +return (pgd_t *)page_address (page); +#endif +} + +static inline void rpgd_free (struct mm_struct *mm,pgd_t *pgd) +{ +#ifdef CONFIG_PPC_64K_PAGES +free_page ((unsigned long )pgd); +#else +free_pages ((unsigned long )pgd,4 ); +#endif +} +static inline pgd_t *pgd_alloc (struct mm_struct *mm) { +if (radix_enabled ()) +return rpgd_alloc (mm);return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),GFP_KERNEL ); }static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) { +if (radix_enabled ()) +return rpgd_free (mm, pgd);kmem_cache_free (PGT_CACHE (PGD_INDEX_SIZE ), pgd); }static inline void pgd_populate (struct mm_struct *mm,pgd_t *pgd,pud_t *pud) { -pgd_set (pgd,__pgtable_ptr_val (pud)); +pgd_set (pgd,__pgtable_ptr_val (pud) |PGD_VAL_BITS ); }static inline pud_t *pud_alloc_one (struct mm_struct *mm,unsigned long addr)
@@ -78,7 +104,7 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)static inline void pud_populate (struct mm_struct *mm,pud_t *pud,pmd_t *pmd) { -pud_set (pud,__pgtable_ptr_val (pmd)); +pud_set (pud,__pgtable_ptr_val (pmd) |PUD_VAL_BITS ); } static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
@@ -107,13 +133,13 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) { -pmd_set (pmd,__pgtable_ptr_val (pte)); +pmd_set (pmd,__pgtable_ptr_val (pte) |PMD_VAL_BITS ); }static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd,pgtable_t pte_page) { -pmd_set (pmd,__pgtable_ptr_val (pte_page)); +pmd_set (pmd,__pgtable_ptr_val (pte_page) |PMD_VAL_BITS ); }static inline pgtable_t pmd_pgtable (pmd_t pmd)
arch/powerpc/include/asm/book3s/64/pgtable.h +8 -2
@@ -170,11 +170,17 @@ extern unsigned long __pgd_table_size;#define PMD_TABLE_SIZE __pmd_table_size#define PUD_TABLE_SIZE __pud_table_size#define PGD_TABLE_SIZE __pgd_table_size + +extern unsigned long __pmd_val_bits; +extern unsigned long __pud_val_bits; +extern unsigned long __pgd_val_bits; +#define PMD_VAL_BITS __pmd_val_bits +#define PUD_VAL_BITS __pud_val_bits +#define PGD_VAL_BITS __pgd_val_bits/* * Pgtable size used by swapper, init in asm code -* We will switch this later to radix PGD */ -#define MAX_PGD_TABLE_SIZE (sizeof(pgd_t) << H_PGD_INDEX_SIZE) +#define MAX_PGD_TABLE_SIZE (sizeof(pgd_t) << R_PGD_INDEX_SIZE)#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
arch/powerpc/mm/hash_utils_64.c +7 -0
@@ -878,6 +878,13 @@ void __init hlearly_init_mmu(void) __pmd_table_size =H_PMD_TABLE_SIZE ; __pud_table_size =H_PUD_TABLE_SIZE ; __pgd_table_size =H_PGD_TABLE_SIZE ; +/* +* 4k use hugepd format, so for hash set then to +* zero +*/ + __pmd_val_bits =0 ; + __pud_val_bits =0 ; + __pgd_val_bits =0 ;/* Initialize the MMU Hash table and create the linear mapping * of memory. Has to be done before SLB initialization as this is * currently where the page size encoding is obtained.
arch/powerpc/mm/pgtable-radix.c +4 -1
@@ -318,8 +318,11 @@ void __init rearly_init_mmu(void) __pud_table_size =R_PUD_TABLE_SIZE ; __pgd_table_size =R_PGD_TABLE_SIZE ; -radix_init_page_sizes (); + __pmd_val_bits =R_PMD_VAL_BITS ; + __pud_val_bits =R_PUD_VAL_BITS ; + __pgd_val_bits =R_PGD_VAL_BITS ; +radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))radix_init_partition_table ();
arch/powerpc/mm/pgtable_64.c +6 -0
@@ -91,6 +91,12 @@ unsigned long __pud_table_size;EXPORT_SYMBOL (__pud_table_size);unsigned long __pgd_table_size;EXPORT_SYMBOL (__pgd_table_size); +unsigned long __pmd_val_bits; +EXPORT_SYMBOL (__pmd_val_bits); +unsigned long __pud_val_bits; +EXPORT_SYMBOL (__pud_val_bits); +unsigned long __pgd_val_bits; +EXPORT_SYMBOL (__pgd_val_bits);#endif unsigned long ioremap_bot =IOREMAP_BASE ;
Signature · 1 line
2.5.0
Re: [PATCH V2 53/68] powerpc/mm: Add radix pgalloc details
Quoted 14 lines · Aneesh Kumar K.V
Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/include/asm/book3s/64/pgalloc.h | 34 ++++++++++++++++++++++++---- arch/powerpc/include/asm/book3s/64/pgtable.h | 10 ++++++-- arch/powerpc/mm/hash_utils_64.c | 7 ++++++ arch/powerpc/mm/pgtable-radix.c | 5 +++- arch/powerpc/mm/pgtable_64.c | 6 +++++ 5 files changed, 55 insertions(+), 7 deletions(-)arch/powerpc/include/asm/book3s/64/pgalloc.h +0
-0
arch/powerpc/include/asm/book3s/64/pgalloc.h extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift); · line 59
Quoted 10 lines
arch/powerpc/include/asm/book3s/64/pgalloc.h +7
-0@@ -50,19 +50,45 @@ extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift);extern void __tlb_remove_table (void *_table);#endif +static inline pgd_t *rpgd_alloc (struct mm_struct *mm) +{ +#ifdef CONFIG_PPC_64K_PAGES +return (pgd_t *)__get_free_page (PGALLOC_GFP ); +#else +struct page *page; + page =alloc_pages (PGALLOC_GFP ,4 );
We need a 2^4*4k = 64k page for PGD even for 4k pages? Why? One concern is that PGALLOC_GFP does not use CMA if I read the PGALLOC_GFP flags correct
Quoted 90 lines
arch/powerpc/include/asm/book3s/64/pgalloc.h +23
-4+if (!page) +return NULL ; +return (pgd_t *)page_address (page); +#endif +} + +static inline void rpgd_free (struct mm_struct *mm,pgd_t *pgd) +{ +#ifdef CONFIG_PPC_64K_PAGES +free_page ((unsigned long )pgd); +#else +free_pages ((unsigned long )pgd,4 ); +#endif +} +static inline pgd_t *pgd_alloc (struct mm_struct *mm) { +if (radix_enabled ()) +return rpgd_alloc (mm);return kmem_cache_alloc (PGT_CACHE (PGD_INDEX_SIZE ),GFP_KERNEL ); }static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) { +if (radix_enabled ()) +return rpgd_free (mm, pgd);kmem_cache_free (PGT_CACHE (PGD_INDEX_SIZE ), pgd); }static inline void pgd_populate (struct mm_struct *mm,pgd_t *pgd,pud_t *pud) { -pgd_set (pgd,__pgtable_ptr_val (pud)); +pgd_set (pgd,__pgtable_ptr_val (pud) |PGD_VAL_BITS ); }static inline pud_t *pud_alloc_one (struct mm_struct *mm,unsigned long addr)@@ -78,7 +104,7 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)static inline void pud_populate (struct mm_struct *mm,pud_t *pud,pmd_t *pmd) { -pud_set (pud,__pgtable_ptr_val (pmd)); +pud_set (pud,__pgtable_ptr_val (pmd) |PUD_VAL_BITS ); } static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,@@ -107,13 +133,13 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd,pte_t *pte) { -pmd_set (pmd,__pgtable_ptr_val (pte)); +pmd_set (pmd,__pgtable_ptr_val (pte) |PMD_VAL_BITS ); }static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd,pgtable_t pte_page) { -pmd_set (pmd,__pgtable_ptr_val (pte_page)); +pmd_set (pmd,__pgtable_ptr_val (pte_page) |PMD_VAL_BITS ); }static inline pgtable_t pmd_pgtable (pmd_t pmd)arch/powerpc/include/asm/book3s/64/pgtable.h +8
-2@@ -170,11 +170,17 @@ extern unsigned long __pgd_table_size;#define PMD_TABLE_SIZE __pmd_table_size#define PUD_TABLE_SIZE __pud_table_size#define PGD_TABLE_SIZE __pgd_table_size + +extern unsigned long __pmd_val_bits; +extern unsigned long __pud_val_bits; +extern unsigned long __pgd_val_bits; +#define PMD_VAL_BITS __pmd_val_bits +#define PUD_VAL_BITS __pud_val_bits +#define PGD_VAL_BITS __pgd_val_bits/* * Pgtable size used by swapper, init in asm code -* We will switch this later to radix PGD */ -#define MAX_PGD_TABLE_SIZE (sizeof(pgd_t) << H_PGD_INDEX_SIZE) +#define MAX_PGD_TABLE_SIZE (sizeof(pgd_t) << R_PGD_INDEX_SIZE)#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)arch/powerpc/mm/hash_utils_64.c +0
-0
arch/powerpc/mm/hash_utils_64.c void __init hlearly_init_mmu(void) · line 882
Quoted 5 lines
arch/powerpc/mm/hash_utils_64.c +2
-0@@ -878,6 +878,13 @@ void __init hlearly_init_mmu(void) __pmd_table_size =H_PMD_TABLE_SIZE ; __pud_table_size =H_PUD_TABLE_SIZE ; __pgd_table_size =H_PGD_TABLE_SIZE ; +/* +* 4k use hugepd format, so for hash set then to
^ them
arch/powerpc/mm/hash_utils_64.c void __init hlearly_init_mmu(void) · line 884
Quoted 2 lines
arch/powerpc/mm/hash_utils_64.c +2
-0+* zero +*/
The comment is not very clear
Quoted 41 lines
arch/powerpc/mm/hash_utils_64.c +3
-0+ __pmd_val_bits =0 ; + __pud_val_bits =0 ; + __pgd_val_bits =0 ;/* Initialize the MMU Hash table and create the linear mapping * of memory. Has to be done before SLB initialization as this is * currently where the page size encoding is obtained. arch/powerpc/mm/pgtable-radix.c +4
-1@@ -318,8 +318,11 @@ void __init rearly_init_mmu(void) __pud_table_size =R_PUD_TABLE_SIZE ; __pgd_table_size =R_PGD_TABLE_SIZE ; -radix_init_page_sizes (); + __pmd_val_bits =R_PMD_VAL_BITS ; + __pud_val_bits =R_PUD_VAL_BITS ; + __pgd_val_bits =R_PGD_VAL_BITS ; +radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))radix_init_partition_table ();arch/powerpc/mm/pgtable_64.c +6
-0@@ -91,6 +91,12 @@ unsigned long __pud_table_size;EXPORT_SYMBOL (__pud_table_size);unsigned long __pgd_table_size;EXPORT_SYMBOL (__pgd_table_size); +unsigned long __pmd_val_bits; +EXPORT_SYMBOL (__pmd_val_bits); +unsigned long __pud_val_bits; +EXPORT_SYMBOL (__pud_val_bits); +unsigned long __pgd_val_bits; +EXPORT_SYMBOL (__pgd_val_bits);#endif unsigned long ioremap_bot =IOREMAP_BASE ;
PATCH v2 54/68 powerpc/mm: Update pte filter for radix
In reply to Aneesh Kumar K.V--- arch/powerpc/mm/pgtable.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/mm/pgtable.c +3 -0
@@ -82,6 +82,9 @@ static struct page *maybe_pte_to_page(pte_t pte)static pte_t set_pte_filter (pte_t pte) { +if (radix_enabled ()) +return pte; + pte =__pte (pte_val (pte) & ~_PAGE_HPTEFLAGS);if (pte_looks_normal (pte) && !(cpu_has_feature (CPU_FTR_COHERENT_ICACHE ) ||cpu_has_feature (CPU_FTR_NOEXECUTE ))) {
Signature · 1 line
2.5.0
Re: [PATCH V2 54/68] powerpc/mm: Update pte filter for radix
Quoted 10 lines · Aneesh Kumar K.V
--- arch/powerpc/mm/pgtable.c | 3 +++ 1 file changed, 3 insertions(+)arch/powerpc/mm/pgtable.c +0
-0
arch/powerpc/mm/pgtable.c static struct page *maybe_pte_to_page(pte_t pte) · line 90
Quoted 9 lines
arch/powerpc/mm/pgtable.c +3
-0@@ -82,6 +82,9 @@ static struct page *maybe_pte_to_page(pte_t pte)static pte_t set_pte_filter (pte_t pte) { +if (radix_enabled ()) +return pte; + pte =__pte (pte_val (pte) & ~_PAGE_HPTEFLAGS);if (pte_looks_normal (pte) && !(cpu_has_feature (CPU_FTR_COHERENT_ICACHE ) ||cpu_has_feature (CPU_FTR_NOEXECUTE ))) {
PATCH v2 55/68 powerpc/mm: VMALLOC abstraction
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/hash.h | 14 +++++++------- arch/powerpc/include/asm/book3s/64/pgtable.h | 15 ++++++++++++--- arch/powerpc/include/asm/book3s/64/radix.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci_64.c | 3 ++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++++ arch/powerpc/mm/pgtable-radix.c | 7 +++++++ arch/powerpc/mm/pgtable_64.c | 13 +++++++++++-- arch/powerpc/mm/slb_low.S | 2 +- 8 files changed, 69 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/book3s/64/hash.h +7 -7
@@ -45,17 +45,17 @@/* * Define the address range of the kernel non-linear virtual area */ -#define KERN_VIRT_START ASM_CONST(0xD000000000000000) -#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) +#define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) +#define H_KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)/* * The vmalloc space starts at the beginning of that region, and * occupies half of it on hash CPUs and a quarter of it on Book3E * (we keep a quarter for the virtual memmap) */ -#define VMALLOC_START KERN_VIRT_START -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) +#define H_VMALLOC_START H_KERN_VIRT_START +#define H_VMALLOC_SIZE (H_KERN_VIRT_SIZE >> 1) +#define H_VMALLOC_END (H_VMALLOC_START + H_VMALLOC_SIZE)/* * Region IDs
@@ -64,7 +64,7 @@#define REGION_MASK (0xfUL << REGION_SHIFT)#define REGION_ID (ea) (((unsigned long)(ea)) >> REGION_SHIFT) -#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) +#define VMALLOC_REGION_ID (REGION_ID(H_VMALLOC_START))#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))#define VMEMMAP_REGION_ID (0xfUL)/* Server only */ #define USER_REGION_ID (0UL)
@@ -73,7 +73,7 @@* Defines the address of the vmemap area, in its own region on * hash table CPUs. */ -#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) +#define H_VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)#ifdef CONFIG_PPC_MM_SLICES #define HAVE_ARCH_UNMAPPED_AREA
arch/powerpc/include/asm/book3s/64/pgtable.h +12 -3
@@ -208,6 +208,18 @@ extern unsigned long __pgd_val_bits;#define PUD_MASKED_BITS 0xc0000000000000ffUL/* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0xc0000000000000ffUL + +extern unsigned long __vmalloc_start; +extern unsigned long __vmalloc_end; +#define VMALLOC_START __vmalloc_start +#define VMALLOC_END __vmalloc_end + +extern unsigned long __kernel_virt_start; +extern unsigned long __kernel_virt_size; +#define KERN_VIRT_START __kernel_virt_start +#define KERN_VIRT_SIZE __kernel_virt_size +extern struct page *vmemmap; +extern unsigned long ioremap_bot;#endif /* __ASSEMBLY__ */ #include <asm/book3s/64/hash.h>
@@ -220,7 +232,6 @@ extern unsigned long __pgd_val_bits;#endif #include <asm/barrier.h> -/* * The second half of the kernel virtual space is used for IO mappings, * it's itself carved into the PIO region (ISA and PHB IO space) and
@@ -239,8 +250,6 @@ extern unsigned long __pgd_val_bits;#define IOREMAP_BASE (PHB_IO_END)#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) -#define vmemmap ((struct page *)VMEMMAP_BASE) -/* Advertise special mapping type for AGP */ #define HAVE_PAGE_AGP
arch/powerpc/include/asm/book3s/64/radix.h +21 -0
@@ -30,6 +30,27 @@#define R_PGTABLE_EADDR_SIZE (R_PTE_INDEX_SIZE + R_PMD_INDEX_SIZE + \ R_PUD_INDEX_SIZE + R_PGD_INDEX_SIZE + PAGE_SHIFT)#define R_PGTABLE_RANGE (ASM_CONST(1) << R_PGTABLE_EADDR_SIZE) +/* +* We support 52 bit address space, Use top bit for kernel +* virtual mapping. Also make sure kernel fit in the top +* quadrant. +*/ +#define R_KERN_VIRT_START ASM_CONST(0xc008000000000000) +#define R_KERN_VIRT_SIZE ASM_CONST(0x0008000000000000) + +/* +* The vmalloc space starts at the beginning of that region, and +* occupies a quarter of it on radix config. +* (we keep a quarter for the virtual memmap) +*/ +#define R_VMALLOC_START R_KERN_VIRT_START +#define R_VMALLOC_SIZE (R_KERN_VIRT_SIZE >> 2) +#define R_VMALLOC_END (R_VMALLOC_START + R_VMALLOC_SIZE) +/* +* Defines the address of the vmemap area, in its own region on +* hash table CPUs. +*/ +#define R_VMEMMAP_BASE (R_VMALLOC_END)#ifndef __ASSEMBLY__#define R_PTE_TABLE_SIZE (sizeof(pte_t) << R_PTE_INDEX_SIZE)
arch/powerpc/kernel/pci_64.c +2 -1
@@ -38,7 +38,7 @@* ISA drivers use hard coded offsets. If no ISA bus exists nothing * is mapped on the first 64K of IO space */ -unsigned long pci_io_base =ISA_IO_BASE ; +unsigned long pci_io_base;EXPORT_SYMBOL (pci_io_base);static int __init pcibios_init (void )
@@ -47,6 +47,7 @@ static int __init pcibios_init(void)printk (KERN_INFO "PCI: Probing PCI hardware\n" ); + pci_io_base =ISA_IO_BASE ;/* For now, override phys_mem_access_prot. If we need it,g * later, we may move that initialization to each ppc_md */
arch/powerpc/mm/hash_utils_64.c +8 -0
@@ -885,6 +885,14 @@ void __init hlearly_init_mmu(void) __pmd_val_bits =0 ; __pud_val_bits =0 ; __pgd_val_bits =0 ; + + __kernel_virt_start =H_KERN_VIRT_START ; + __kernel_virt_size =H_KERN_VIRT_SIZE ; + __vmalloc_start =H_VMALLOC_START ; + __vmalloc_end =H_VMALLOC_END ; + vmemmap = (struct page *)H_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +/* Initialize the MMU Hash table and create the linear mapping * of memory. Has to be done before SLB initialization as this is * currently where the page size encoding is obtained.
arch/powerpc/mm/pgtable-radix.c +7 -0
@@ -322,6 +322,13 @@ void __init rearly_init_mmu(void) __pud_val_bits =R_PUD_VAL_BITS ; __pgd_val_bits =R_PGD_VAL_BITS ; + __kernel_virt_start =R_KERN_VIRT_START ; + __kernel_virt_size =R_KERN_VIRT_SIZE ; + __vmalloc_start =R_VMALLOC_START ; + __vmalloc_end =R_VMALLOC_END ; + vmemmap = (struct page *)R_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))radix_init_partition_table ();
arch/powerpc/mm/pgtable_64.c +11 -2
@@ -97,9 +97,18 @@ unsigned long __pud_val_bits;EXPORT_SYMBOL (__pud_val_bits);unsigned long __pgd_val_bits;EXPORT_SYMBOL (__pgd_val_bits); - +unsigned long __kernel_virt_start; +EXPORT_SYMBOL (__kernel_virt_start); +unsigned long __kernel_virt_size; +EXPORT_SYMBOL (__kernel_virt_size); +unsigned long __vmalloc_start; +EXPORT_SYMBOL (__vmalloc_start); +unsigned long __vmalloc_end; +EXPORT_SYMBOL (__vmalloc_end); +struct page *vmemmap; +EXPORT_SYMBOL (vmemmap);#endif -unsigned long ioremap_bot =IOREMAP_BASE ; +unsigned long ioremap_bot;/** * __ioremap_at - Low level function to establish the page tables
arch/powerpc/mm/slb_low.S +1 -1
@@ -91,7 +91,7 @@ slb_miss_kernel_load_vmemmap: * can be demoted from 64K -> 4K dynamically on some machines */ clrldi r11,r10,48 - cmpldi r11,(VMALLOC_SIZE >> 28) - 1 + cmpldi r11,(H_VMALLOC_SIZE >> 28) - 1 bgt 5f lhz r11,PACAVMALLOCSLLP(r13) b 6f
Signature · 1 line
2.5.0
Re: [PATCH V2 55/68] powerpc/mm: VMALLOC abstraction
Aneesh,
I'm not sure why we need this patch.
It seems to be moving the initialisation of some global variables into init functions from the definitions. And renames some things.
Quoted 17 lines
arch/powerpc/kernel/pci_64.c +1
-1@@ -38,7 +38,7 @@* ISA drivers use hard coded offsets. If no ISA bus exists nothing * is mapped on the first 64K of IO space */ -unsigned long pci_io_base =3D ISA_IO_BASE; +unsigned long pci_io_base;EXPORT_SYMBOL (pci_io_base);=20
static int__initpcibios_init(void)arch/powerpc/kernel/pci_64.c +0
-0@@ -47,6 +47,7 @@ static int __init pcibios_init(void)=20
printk(KERN_INFO "PCI: Probing PCI hardware\n");
=20
arch/powerpc/kernel/pci_64.c
Quoted 1 line
arch/powerpc/kernel/pci_64.c +1
-0+ pci_io_base =3D ISA_IO_BASE;
Did you mean to change this in this patch? This seems to be a random change in pci code.
Mikey
Re: [PATCH V2 55/68] powerpc/mm: VMALLOC abstraction
Quoted 6 lines · Michael Neuling
Aneesh,
I'm not sure why we need this patch.
It seems to be moving the initialisation of some global variables into init functions from the definitions. And renames some things.
because the value to which it is getting initialized is no more a constant.
Quoted 16 lines
Quoted 16 lines
arch/powerpc/kernel/pci_64.c +1
-1@@ -38,7 +38,7 @@* ISA drivers use hard coded offsets. If no ISA bus exists nothing * is mapped on the first 64K of IO space */ -unsigned long pci_io_base =ISA_IO_BASE ; +unsigned long pci_io_base;EXPORT_SYMBOL (pci_io_base);static int __init pcibios_init (void )@@ -47,6 +47,7 @@ static int __init pcibios_init(void)
Quoted 7 lines
arch/powerpc/kernel/pci_64.c static int __init pcibios_init(void) · line 50
Quoted 3 lines
arch/powerpc/kernel/pci_64.c +1
-0printk (KERN_INFO "PCI: Probing PCI hardware\n" ); + pci_io_base =ISA_IO_BASE ;Did you mean to change this in this patch? This seems to be a random change in pci code.
ISA_IO_BASE is not a constant now.
-aneesh
Re: [PATCH V2 55/68] powerpc/mm: VMALLOC abstraction
Quoted 4 lines · Aneesh Kumar K.V
Quoted 2 lines · Michael Neuling
Aneesh,
Quoted 9 lines
Quoted 4 lines
I'm not sure why we need this patch.
It seems to be moving the initialisation of some global variables into init functions from the definitions. And renames some things.
because the value to which it is getting initialized is no more a constant.
Isn't it still a constant depending on the type of page table? Or is it a run time value depending on the chosen page table type?
Balbir Singh
Re: [PATCH V2 55/68] powerpc/mm: VMALLOC abstraction
In reply to Aneesh Kumar K.VQuoted 116 lines · Aneesh Kumar K.V
Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/include/asm/book3s/64/hash.h | 14 +++++++------- arch/powerpc/include/asm/book3s/64/pgtable.h | 15 ++++++++++++--- arch/powerpc/include/asm/book3s/64/radix.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci_64.c | 3 ++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++++ arch/powerpc/mm/pgtable-radix.c | 7 +++++++ arch/powerpc/mm/pgtable_64.c | 13 +++++++++++-- arch/powerpc/mm/slb_low.S | 2 +- 8 files changed, 69 insertions(+), 14 deletions(-)arch/powerpc/include/asm/book3s/64/hash.h +7
-7@@ -45,17 +45,17 @@/* * Define the address range of the kernel non-linear virtual area */ -#define KERN_VIRT_START ASM_CONST(0xD000000000000000) -#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) +#define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) +#define H_KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)/* * The vmalloc space starts at the beginning of that region, and * occupies half of it on hash CPUs and a quarter of it on Book3E * (we keep a quarter for the virtual memmap) */ -#define VMALLOC_START KERN_VIRT_START -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) +#define H_VMALLOC_START H_KERN_VIRT_START +#define H_VMALLOC_SIZE (H_KERN_VIRT_SIZE >> 1) +#define H_VMALLOC_END (H_VMALLOC_START + H_VMALLOC_SIZE)/* * Region IDs @@ -64,7 +64,7 @@#define REGION_MASK (0xfUL << REGION_SHIFT)#define REGION_ID (ea) (((unsigned long)(ea)) >> REGION_SHIFT) -#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) +#define VMALLOC_REGION_ID (REGION_ID(H_VMALLOC_START))#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))#define VMEMMAP_REGION_ID (0xfUL)/* Server only */ #define USER_REGION_ID (0UL)@@ -73,7 +73,7 @@* Defines the address of the vmemap area, in its own region on * hash table CPUs. */ -#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) +#define H_VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)#ifdef CONFIG_PPC_MM_SLICES #define HAVE_ARCH_UNMAPPED_AREA arch/powerpc/include/asm/book3s/64/pgtable.h +12
-3@@ -208,6 +208,18 @@ extern unsigned long __pgd_val_bits;#define PUD_MASKED_BITS 0xc0000000000000ffUL/* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0xc0000000000000ffUL + +extern unsigned long __vmalloc_start; +extern unsigned long __vmalloc_end; +#define VMALLOC_START __vmalloc_start +#define VMALLOC_END __vmalloc_end + +extern unsigned long __kernel_virt_start; +extern unsigned long __kernel_virt_size; +#define KERN_VIRT_START __kernel_virt_start +#define KERN_VIRT_SIZE __kernel_virt_size +extern struct page *vmemmap; +extern unsigned long ioremap_bot;#endif /* __ASSEMBLY__ */ #include <asm/book3s/64/hash.h> @@ -220,7 +232,6 @@ extern unsigned long __pgd_val_bits;#endif #include <asm/barrier.h> -/* * The second half of the kernel virtual space is used for IO mappings, * it's itself carved into the PIO region (ISA and PHB IO space) and @@ -239,8 +250,6 @@ extern unsigned long __pgd_val_bits;#define IOREMAP_BASE (PHB_IO_END)#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) -#define vmemmap ((struct page *)VMEMMAP_BASE) -/* Advertise special mapping type for AGP */ #define HAVE_PAGE_AGP arch/powerpc/include/asm/book3s/64/radix.h +11
-0@@ -30,6 +30,27 @@#define R_PGTABLE_EADDR_SIZE (R_PTE_INDEX_SIZE + R_PMD_INDEX_SIZE + \ R_PUD_INDEX_SIZE + R_PGD_INDEX_SIZE + PAGE_SHIFT)#define R_PGTABLE_RANGE (ASM_CONST(1) << R_PGTABLE_EADDR_SIZE) +/* +* We support 52 bit address space, Use top bit for kernel +* virtual mapping. Also make sure kernel fit in the top +* quadrant. +*/ +#define R_KERN_VIRT_START ASM_CONST(0xc008000000000000) +#define R_KERN_VIRT_SIZE ASM_CONST(0x0008000000000000) + +/* +* The vmalloc space starts at the beginning of that region, and +* occupies a quarter of it on radix config.
arch/powerpc/include/asm/book3s/64/radix.h line 53
Quoted 10 lines
arch/powerpc/include/asm/book3s/64/radix.h +10
-0+* (we keep a quarter for the virtual memmap) +*/ +#define R_VMALLOC_START R_KERN_VIRT_START +#define R_VMALLOC_SIZE (R_KERN_VIRT_SIZE >> 2) +#define R_VMALLOC_END (R_VMALLOC_START + R_VMALLOC_SIZE) +/* +* Defines the address of the vmemap area, in its own region on +* hash table CPUs. +*/ +#define R_VMEMMAP_BASE (R_VMALLOC_END)
Does this still fit in the 52 bit space?
Quoted 100 lines
arch/powerpc/include/asm/book3s/64/radix.h +0
-0#ifndef __ASSEMBLY__#define R_PTE_TABLE_SIZE (sizeof(pte_t) << R_PTE_INDEX_SIZE)arch/powerpc/kernel/pci_64.c +2
-1@@ -38,7 +38,7 @@* ISA drivers use hard coded offsets. If no ISA bus exists nothing * is mapped on the first 64K of IO space */ -unsigned long pci_io_base =ISA_IO_BASE ; +unsigned long pci_io_base;EXPORT_SYMBOL (pci_io_base);static int __init pcibios_init (void )@@ -47,6 +47,7 @@ static int __init pcibios_init(void)printk (KERN_INFO "PCI: Probing PCI hardware\n" ); + pci_io_base =ISA_IO_BASE ;/* For now, override phys_mem_access_prot. If we need it,g * later, we may move that initialization to each ppc_md */ arch/powerpc/mm/hash_utils_64.c +8
-0@@ -885,6 +885,14 @@ void __init hlearly_init_mmu(void) __pmd_val_bits =0 ; __pud_val_bits =0 ; __pgd_val_bits =0 ; + + __kernel_virt_start =H_KERN_VIRT_START ; + __kernel_virt_size =H_KERN_VIRT_SIZE ; + __vmalloc_start =H_VMALLOC_START ; + __vmalloc_end =H_VMALLOC_END ; + vmemmap = (struct page *)H_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +/* Initialize the MMU Hash table and create the linear mapping * of memory. Has to be done before SLB initialization as this is * currently where the page size encoding is obtained. arch/powerpc/mm/pgtable-radix.c +7
-0@@ -322,6 +322,13 @@ void __init rearly_init_mmu(void) __pud_val_bits =R_PUD_VAL_BITS ; __pgd_val_bits =R_PGD_VAL_BITS ; + __kernel_virt_start =R_KERN_VIRT_START ; + __kernel_virt_size =R_KERN_VIRT_SIZE ; + __vmalloc_start =R_VMALLOC_START ; + __vmalloc_end =R_VMALLOC_END ; + vmemmap = (struct page *)R_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))radix_init_partition_table ();arch/powerpc/mm/pgtable_64.c +11
-2@@ -97,9 +97,18 @@ unsigned long __pud_val_bits;EXPORT_SYMBOL (__pud_val_bits);unsigned long __pgd_val_bits;EXPORT_SYMBOL (__pgd_val_bits); - +unsigned long __kernel_virt_start; +EXPORT_SYMBOL (__kernel_virt_start); +unsigned long __kernel_virt_size; +EXPORT_SYMBOL (__kernel_virt_size); +unsigned long __vmalloc_start; +EXPORT_SYMBOL (__vmalloc_start); +unsigned long __vmalloc_end; +EXPORT_SYMBOL (__vmalloc_end); +struct page *vmemmap; +EXPORT_SYMBOL (vmemmap);#endif -unsigned long ioremap_bot =IOREMAP_BASE ; +unsigned long ioremap_bot;/** * __ioremap_at - Low level function to establish the page tables arch/powerpc/mm/slb_low.S +1
-1@@ -91,7 +91,7 @@ slb_miss_kernel_load_vmemmap: * can be demoted from 64K -> 4K dynamically on some machines */ clrldi r11,r10,48 - cmpldi r11,(VMALLOC_SIZE >> 28) - 1 + cmpldi r11,(H_VMALLOC_SIZE >> 28) - 1 bgt 5f lhz r11,PACAVMALLOCSLLP(r13) b 6f
Re: [PATCH V2 55/68] powerpc/mm: VMALLOC abstraction
In reply to Aneesh Kumar K.Vvmalloc range differs between hash and radix config. Hence make VMALLOC_START and related constants a variable which get runtime initialized depending on hash or radix.
Quoted 227 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/include/asm/book3s/64/hash.h | 14 +++++++------- arch/powerpc/include/asm/book3s/64/pgtable.h | 15 ++++++++++++--- arch/powerpc/include/asm/book3s/64/radix.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci_64.c | 3 ++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++++ arch/powerpc/mm/pgtable-radix.c | 7 +++++++ arch/powerpc/mm/pgtable_64.c | 13 +++++++++++-- arch/powerpc/mm/slb_low.S | 2 +- 8 files changed, 69 insertions(+), 14 deletions(-)arch/powerpc/include/asm/book3s/64/hash.h +7
-7@@ -45,17 +45,17 @@/* * Define the address range of the kernel non-linear virtual area */ -#define KERN_VIRT_START ASM_CONST(0xD000000000000000) -#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) +#define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) +#define H_KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)/* * The vmalloc space starts at the beginning of that region, and * occupies half of it on hash CPUs and a quarter of it on Book3E * (we keep a quarter for the virtual memmap) */ -#define VMALLOC_START KERN_VIRT_START -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) +#define H_VMALLOC_START H_KERN_VIRT_START +#define H_VMALLOC_SIZE (H_KERN_VIRT_SIZE >> 1) +#define H_VMALLOC_END (H_VMALLOC_START + H_VMALLOC_SIZE)/* * Region IDs @@ -64,7 +64,7 @@#define REGION_MASK (0xfUL << REGION_SHIFT)#define REGION_ID (ea) (((unsigned long)(ea)) >> REGION_SHIFT) -#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) +#define VMALLOC_REGION_ID (REGION_ID(H_VMALLOC_START))#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))#define VMEMMAP_REGION_ID (0xfUL)/* Server only */ #define USER_REGION_ID (0UL)@@ -73,7 +73,7 @@* Defines the address of the vmemap area, in its own region on * hash table CPUs. */ -#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) +#define H_VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)#ifdef CONFIG_PPC_MM_SLICES #define HAVE_ARCH_UNMAPPED_AREA arch/powerpc/include/asm/book3s/64/pgtable.h +12
-3@@ -208,6 +208,18 @@ extern unsigned long __pgd_val_bits;#define PUD_MASKED_BITS 0xc0000000000000ffUL/* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0xc0000000000000ffUL + +extern unsigned long __vmalloc_start; +extern unsigned long __vmalloc_end; +#define VMALLOC_START __vmalloc_start +#define VMALLOC_END __vmalloc_end + +extern unsigned long __kernel_virt_start; +extern unsigned long __kernel_virt_size; +#define KERN_VIRT_START __kernel_virt_start +#define KERN_VIRT_SIZE __kernel_virt_size +extern struct page *vmemmap; +extern unsigned long ioremap_bot;#endif /* __ASSEMBLY__ */ #include <asm/book3s/64/hash.h> @@ -220,7 +232,6 @@ extern unsigned long __pgd_val_bits;#endif #include <asm/barrier.h> -/* * The second half of the kernel virtual space is used for IO mappings, * it's itself carved into the PIO region (ISA and PHB IO space) and @@ -239,8 +250,6 @@ extern unsigned long __pgd_val_bits;#define IOREMAP_BASE (PHB_IO_END)#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) -#define vmemmap ((struct page *)VMEMMAP_BASE) -/* Advertise special mapping type for AGP */ #define HAVE_PAGE_AGP arch/powerpc/include/asm/book3s/64/radix.h +21
-0@@ -30,6 +30,27 @@#define R_PGTABLE_EADDR_SIZE (R_PTE_INDEX_SIZE + R_PMD_INDEX_SIZE + \ R_PUD_INDEX_SIZE + R_PGD_INDEX_SIZE + PAGE_SHIFT)#define R_PGTABLE_RANGE (ASM_CONST(1) << R_PGTABLE_EADDR_SIZE) +/* +* We support 52 bit address space, Use top bit for kernel +* virtual mapping. Also make sure kernel fit in the top +* quadrant. +*/ +#define R_KERN_VIRT_START ASM_CONST(0xc008000000000000) +#define R_KERN_VIRT_SIZE ASM_CONST(0x0008000000000000) + +/* +* The vmalloc space starts at the beginning of that region, and +* occupies a quarter of it on radix config. +* (we keep a quarter for the virtual memmap) +*/ +#define R_VMALLOC_START R_KERN_VIRT_START +#define R_VMALLOC_SIZE (R_KERN_VIRT_SIZE >> 2) +#define R_VMALLOC_END (R_VMALLOC_START + R_VMALLOC_SIZE) +/* +* Defines the address of the vmemap area, in its own region on +* hash table CPUs. +*/ +#define R_VMEMMAP_BASE (R_VMALLOC_END)#ifndef __ASSEMBLY__#define R_PTE_TABLE_SIZE (sizeof(pte_t) << R_PTE_INDEX_SIZE)arch/powerpc/kernel/pci_64.c +2
-1@@ -38,7 +38,7 @@* ISA drivers use hard coded offsets. If no ISA bus exists nothing * is mapped on the first 64K of IO space */ -unsigned long pci_io_base =ISA_IO_BASE ; +unsigned long pci_io_base;EXPORT_SYMBOL (pci_io_base);static int __init pcibios_init (void )@@ -47,6 +47,7 @@ static int __init pcibios_init(void)printk (KERN_INFO "PCI: Probing PCI hardware\n" ); + pci_io_base =ISA_IO_BASE ;/* For now, override phys_mem_access_prot. If we need it,g * later, we may move that initialization to each ppc_md */ arch/powerpc/mm/hash_utils_64.c +8
-0@@ -885,6 +885,14 @@ void __init hlearly_init_mmu(void) __pmd_val_bits =0 ; __pud_val_bits =0 ; __pgd_val_bits =0 ; + + __kernel_virt_start =H_KERN_VIRT_START ; + __kernel_virt_size =H_KERN_VIRT_SIZE ; + __vmalloc_start =H_VMALLOC_START ; + __vmalloc_end =H_VMALLOC_END ; + vmemmap = (struct page *)H_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +/* Initialize the MMU Hash table and create the linear mapping * of memory. Has to be done before SLB initialization as this is * currently where the page size encoding is obtained. arch/powerpc/mm/pgtable-radix.c +7
-0@@ -322,6 +322,13 @@ void __init rearly_init_mmu(void) __pud_val_bits =R_PUD_VAL_BITS ; __pgd_val_bits =R_PGD_VAL_BITS ; + __kernel_virt_start =R_KERN_VIRT_START ; + __kernel_virt_size =R_KERN_VIRT_SIZE ; + __vmalloc_start =R_VMALLOC_START ; + __vmalloc_end =R_VMALLOC_END ; + vmemmap = (struct page *)R_VMEMMAP_BASE ; + ioremap_bot =IOREMAP_BASE ; +radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))radix_init_partition_table ();arch/powerpc/mm/pgtable_64.c +11
-2@@ -97,9 +97,18 @@ unsigned long __pud_val_bits;EXPORT_SYMBOL (__pud_val_bits);unsigned long __pgd_val_bits;EXPORT_SYMBOL (__pgd_val_bits); - +unsigned long __kernel_virt_start; +EXPORT_SYMBOL (__kernel_virt_start); +unsigned long __kernel_virt_size; +EXPORT_SYMBOL (__kernel_virt_size); +unsigned long __vmalloc_start; +EXPORT_SYMBOL (__vmalloc_start); +unsigned long __vmalloc_end; +EXPORT_SYMBOL (__vmalloc_end); +struct page *vmemmap; +EXPORT_SYMBOL (vmemmap);#endif -unsigned long ioremap_bot =IOREMAP_BASE ; +unsigned long ioremap_bot;/** * __ioremap_at - Low level function to establish the page tables arch/powerpc/mm/slb_low.S +1
-1@@ -91,7 +91,7 @@ slb_miss_kernel_load_vmemmap: * can be demoted from 64K -> 4K dynamically on some machines */ clrldi r11,r10,48 - cmpldi r11,(VMALLOC_SIZE >> 28) - 1 + cmpldi r11,(H_VMALLOC_SIZE >> 28) - 1 bgt 5f lhz r11,PACAVMALLOCSLLP(r13) b 6fSignature · 1 line
2.5.0
PATCH v2 56/68 powerpc/radix: update mmu cache
In reply to Aneesh Kumar K.VWith radix there is no mmu cache. Hence we don't need to do much in update_mmu_cache.
--- arch/powerpc/mm/mem.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/mm/mem.c +2 -0
@@ -499,6 +499,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,* called with either mm->page_table_lock held or ptl lock held */ unsigned long access =0 , trap; +if (radix_enabled ()) +return ;/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ if (!pte_young (*ptep) || address >=TASK_SIZE )
Signature · 1 line
2.5.0
Re: [PATCH V2 56/68] powerpc/radix: update mmu cache
Quoted 14 lines · Aneesh Kumar K.V
With radix there is no mmu cache. Hence we don't need to do much in
update_mmu_cache.Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/mm/mem.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/mm/mem.c +0
-0
arch/powerpc/mm/mem.c void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, · line 506
Quoted 8 lines
arch/powerpc/mm/mem.c +2
-0@@ -499,6 +499,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,* called with either mm->page_table_lock held or ptl lock held */ unsigned long access =0 , trap; +if (radix_enabled ()) +return ;/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ if (!pte_young (*ptep) || address >=TASK_SIZE )
PATCH v2 57/68 powerpc/mm: pte_frag abstraction
In reply to Aneesh Kumar K.VIn this patch we make the number of pte fragments per level4 page table page a variable. Radix level 4 table size is 256 bytes and hence we can have 256 fragments per level4 page. We don't update the fragment count in this patch. We need to do performance measurements to find the right value for fragment count.
--- arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 ++ arch/powerpc/include/asm/book3s/64/hash-64k.h | 4 ++-- arch/powerpc/include/asm/book3s/64/pgtable.h | 6 ++++++ arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/pgtable-radix.c | 5 +++++ arch/powerpc/mm/pgtable_64.c | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +2 -0
@@ -28,6 +28,8 @@#define H_PAGE_4K_PFN 0x0#define H_PAGE_THP_HUGE 0x0#define H_PAGE_COMBO 0x0 +#define H_PTE_FRAG_NR 0 +#define H_PTE_FRAG_SIZE_SHIFT 0/* * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range() */
arch/powerpc/include/asm/book3s/64/hash-64k.h +2 -2
@@ -29,12 +29,12 @@/* * we support 16 fragments per PTE page of 64K size. */ -#define PTE_FRAG_NR 16 +#define H_PTE_FRAG_NR 16/* * We use a 2K PTE page fragment and another 2K for storing * real_pte_t hash index */ -#define PTE_FRAG_SIZE_SHIFT 12 +#define H_PTE_FRAG_SIZE_SHIFT 12#define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)#ifndef __ASSEMBLY__
arch/powerpc/include/asm/book3s/64/pgtable.h +6 -0
@@ -177,6 +177,12 @@ extern unsigned long __pgd_val_bits;#define PMD_VAL_BITS __pmd_val_bits#define PUD_VAL_BITS __pud_val_bits#define PGD_VAL_BITS __pgd_val_bits + +extern unsigned long __pte_frag_nr; +#define PTE_FRAG_NR __pte_frag_nr +extern unsigned long __pte_frag_size_shift; +#define PTE_FRAG_SIZE_SHIFT __pte_frag_size_shift +#define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)/* * Pgtable size used by swapper, init in asm code */
arch/powerpc/mm/hash_utils_64.c +3 -0
@@ -869,6 +869,9 @@ void __init hlearly_init_mmu(void)/* * initialize page table size */ + __pte_frag_nr =H_PTE_FRAG_NR ; + __pte_frag_size_shift =H_PTE_FRAG_SIZE_SHIFT ; + __pte_index_size =H_PTE_INDEX_SIZE ; __pmd_index_size =H_PMD_INDEX_SIZE ; __pud_index_size =H_PUD_INDEX_SIZE ;
arch/powerpc/mm/pgtable-radix.c +5 -0
@@ -328,6 +328,11 @@ void __init rearly_init_mmu(void) __vmalloc_end =R_VMALLOC_END ; vmemmap = (struct page *)R_VMEMMAP_BASE ; ioremap_bot =IOREMAP_BASE ; +/* +* For now radix also use the same frag size +*/ + __pte_frag_nr =H_PTE_FRAG_NR ; + __pte_frag_size_shift =H_PTE_FRAG_SIZE_SHIFT ;radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR ))
arch/powerpc/mm/pgtable_64.c +4 -0
@@ -107,6 +107,10 @@ unsigned long __vmalloc_end;EXPORT_SYMBOL (__vmalloc_end);struct page *vmemmap;EXPORT_SYMBOL (vmemmap); +unsigned long __pte_frag_nr; +EXPORT_SYMBOL (__pte_frag_nr); +unsigned long __pte_frag_size_shift; +EXPORT_SYMBOL (__pte_frag_size_shift);#endif unsigned long ioremap_bot;
Signature · 1 line
2.5.0
PATCH v2 58/68 powerpc/mm: Fix vma_mmu_pagesize for radix
In reply to Aneesh Kumar K.VRadix don't use SLICE framework to find page size. Hence use vma to find the page size.
--- arch/powerpc/mm/hugetlbpage.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/mm/hugetlbpage.c +4 -4
@@ -719,14 +719,14 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) {#ifdef CONFIG_PPC_MM_SLICES unsigned int psize =get_slice_psize (vma->vm_mm, vma->vm_start); - -return 1UL <<mmu_psize_to_shift (psize); -#else +/* With radix we don't use slice, so derive it from vma*/ +if (!radix_enabled ()) +return 1UL <<mmu_psize_to_shift (psize); +#endif if (!is_vm_hugetlb_page (vma))return PAGE_SIZE ;return huge_page_size (hstate_vma (vma)); -#endif }static inline bool is_power_of_4 (unsigned long x)
Signature · 1 line
2.5.0
PATCH v2 59/68 powerpc/mm: Add radix support for hugetlb
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/hugetlb-radix.h | 14 ++++ arch/powerpc/include/asm/hugetlb.h | 14 ++++ arch/powerpc/mm/Makefile | 1 + arch/powerpc/mm/hugetlbpage-radix.c | 87 ++++++++++++++++++++++ arch/powerpc/mm/hugetlbpage.c | 8 +- arch/powerpc/mm/tlb-radix.c | 9 +++ 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/book3s/64/hugetlb-radix.h create mode 100644 arch/powerpc/mm/hugetlbpage-radix.c
arch/powerpc/include/asm/book3s/64/hugetlb-radix.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _ASM_POWERPC_BOOK3S_64_HUGETLB_RADIX_H +#define _ASM_POWERPC_BOOK3S_64_HUGETLB_RADIX_H +/* +* For radix we want generic code to handle hugetlb. But then if we want +* both hash and radix to be enabled together we need to workaround the +* limitations. +*/ +void flush_hugetlb_rpage (struct vm_area_struct *vma,unsigned long vmaddr); +void __local_flush_hugetlb_rpage (struct vm_area_struct *vma,unsigned long vmaddr); +extern unsigned long +hugetlb_get_radix_unmapped_area (struct file *file,unsigned long addr, +unsigned long len,unsigned long pgoff, +unsigned long flags); +#endif
arch/powerpc/include/asm/hugetlb.h +14 -0
@@ -8,6 +8,8 @@extern struct kmem_cache *hugepte_cache;#ifdef CONFIG_PPC_BOOK3S_64 + +#include <asm/book3s/64/hugetlb-radix.h> /* * This should work for other subarchs too. But right now we use the * new format only for 64bit book3s
@@ -31,7 +33,19 @@ static inline unsigned int hugepd_shift(hugepd_t hpd) {return mmu_psize_to_shift (hugepd_mmu_psize (hpd)); } +static inline void flush_hugetlb_page (struct vm_area_struct *vma, +unsigned long vmaddr) +{ +if (radix_enabled ()) +return flush_hugetlb_rpage (vma, vmaddr); +} +static inline void __local_flush_hugetlb_page (struct vm_area_struct *vma, +unsigned long vmaddr) +{ +if (radix_enabled ()) +return __local_flush_hugetlb_rpage (vma, vmaddr); +}#else static inline pte_t *hugepd_page (hugepd_t hpd)
arch/powerpc/mm/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_PPC_MM_SLICES) += slice.o obj-y += hugetlbpage.o ifeq ($(CONFIG_HUGETLB_PAGE),y) obj-$(CONFIG_PPC_STD_MMU_64) += hugetlbpage-hash64.o +obj-$(CONFIG_PPC_RADIX_MMU) += hugetlbpage-radix.o obj-$(CONFIG_PPC_BOOK3E_MMU) += hugetlbpage-book3e.o endif obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hugepage-hash64.o
arch/powerpc/mm/hugetlbpage-radix.c new file +87 -0
87 lines not on this page · raw message
arch/powerpc/mm/hugetlbpage.c +7 -1
@@ -711,6 +711,9 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,struct hstate *hstate =hstate_file (file);int mmu_psize =shift_to_mmu_psize (huge_page_shift (hstate)); +if (radix_enabled ()) +return hugetlb_get_radix_unmapped_area (file, addr, len, + pgoff, flags); return slice_get_unmapped_area(addr, len, flags, mmu_psize, 1); }#endif
@@ -823,7 +826,7 @@ static int __init hugetlbpage_init(void) {int psize; -if (!mmu_has_feature (MMU_FTR_16M_PAGE )) +if (!radix_enabled () && !mmu_has_feature (MMU_FTR_16M_PAGE ))return -ENODEV ;for (psize =0 ; psize <MMU_PAGE_COUNT ; ++psize) {
@@ -863,6 +866,9 @@ static int __init hugetlbpage_init(void)HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_16M ].shift; else if (mmu_psize_defs[MMU_PAGE_1M].shift)HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_1M ].shift; + else if (mmu_psize_defs[MMU_PAGE_2M].shift) +HPAGE_SHIFT = mmu_psize_defs[MMU_PAGE_2M ].shift; +return 0 ; }
arch/powerpc/mm/tlb-radix.c +9 -0
@@ -142,6 +142,11 @@ void __local_flush_rtlb_page(struct mm_struct *mm, unsigned long vmaddr,void local_flush_rtlb_page (struct vm_area_struct *vma,unsigned long vmaddr) { +#ifdef CONFIG_HUGETLB_PAGE +/* need the return fix for nohash.c */ +if (vma &&is_vm_hugetlb_page (vma)) +return __local_flush_hugetlb_page (vma, vmaddr); +#endif __local_flush_rtlb_page (vma ? vma->vm_mm :NULL , vmaddr,mmu_get_ap (mmu_virtual_psize),0 ); }
@@ -203,6 +208,10 @@ bail:void flush_rtlb_page (struct vm_area_struct *vma,unsigned long vmaddr) { +#ifdef CONFIG_HUGETLB_PAGE +if (vma &&is_vm_hugetlb_page (vma)) +return flush_hugetlb_page (vma, vmaddr); +#endif __flush_rtlb_page (vma ? vma->vm_mm :NULL , vmaddr,mmu_get_ap (mmu_virtual_psize),0 ); }
Signature · 1 line
2.5.0
PATCH v2 60/68 powerpc/mm/radix: Make sure swapper pgdir is properly aligned
In reply to Aneesh Kumar K.VWith 4k page size radix config our level 1 page table size 64K and it should naturally aligned
--- arch/powerpc/kernel/head_64.S | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/powerpc/kernel/head_64.S +8 -5
@@ -973,13 +973,16 @@ start_here_common: * This stuff goes at the beginning of the bss, which is page-aligned. */ .section ".bss" +/* + * pgd dir should be aligned to PGD_TABLE_SIZE which is 64K. + * We will need to find a better way to fix this + */ + .align 16 - .align PAGE_SHIFT + .globl swapper_pg_dir +swapper_pg_dir: + .space PGD_TABLE_SIZE .globl empty_zero_page empty_zero_page: .space PAGE_SIZE - - .globl swapper_pg_dir -swapper_pg_dir: - .space PGD_TABLE_SIZE
Signature · 1 line
2.5.0
PATCH v2 61/68 powerpc/mm/radix: Add hugetlb support 4K page size
In reply to Aneesh Kumar K.VWe have hugepage at the pmd level with 4K radix config. Hence we don't need to use hugepd format with radix.
--- arch/powerpc/include/asm/book3s/64/hash-4k.h | 22 +----------- arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 46 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 21 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +1 -21
@@ -37,26 +37,7 @@ remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, (prot))#ifdef CONFIG_HUGETLB_PAGE -/* -* For 4k page size, we support explicit hugepage via hugepd -*/ -static inline int pmd_huge (pmd_t pmd) -{ -return 0 ; -} - -static inline int pud_huge (pud_t pud) -{ -return 0 ; -} - -static inline int pgd_huge (pgd_t pgd) -{ -return 0 ; -} -#define pgd_huge pgd_huge - -static inline int hugepd_ok (hugepd_t hpd) +static inline int hl_hugepd_ok (hugepd_t hpd) {/* * if it is not a pte and have hugepd shift mask
@@ -67,7 +48,6 @@ static inline int hugepd_ok(hugepd_t hpd)return true;return false; } -#define is_hugepd (hpd) (hugepd_ok(hpd))#endif #endif /* !__ASSEMBLY__ */
arch/powerpc/include/asm/book3s/64/pgtable-4k.h +46 -0
51 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v2 62/68 powerpc/mm: Drop PTE_ATOMIC_UPDATES from pmd_hugepage_update
In reply to Aneesh Kumar K.VTHP is only supported by hash64 now and for that we should always have PTE_ATOMIC_UPDATES always set. Drop the unnecessary #ifdef in the code.
--- arch/powerpc/mm/pgtable_64.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
arch/powerpc/mm/pgtable_64.c +1 -5
@@ -475,7 +475,6 @@ unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr,assert_spin_locked (&mm->page_table_lock);#endif -#ifdef PTE_ATOMIC_UPDATES clr =cpu_to_be64 (clr); set =cpu_to_be64 (set); __asm__ __volatile__(
@@ -491,10 +490,7 @@ unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, : "cc" ); old =be64_to_cpu (old); -#else - old =pmd_val (*pmdp); - *pmdp =__pmd ((old & ~clr) | set); -#endif +trace_hugepage_update (addr, old, clr, set);if (old &H_PAGE_HASHPTE )hpte_do_hugepage_flush (mm, addr, pmdp, old);
Signature · 1 line
2.5.0
PATCH v2 63/68 powerpc/mm: THP is only available on hash64 as of now
In reply to Aneesh Kumar K.VOnly code movement in this patch. No functionality change.
--- arch/powerpc/include/asm/book3s/64/pgtable.h | 24 +- arch/powerpc/mm/pgtable-hash64.c | 363 ++++++++++++++++++++++++++- arch/powerpc/mm/pgtable_64.c | 360 -------------------------- 3 files changed, 371 insertions(+), 376 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable.h +11 -13
@@ -777,18 +777,6 @@ static inline void vmemmap_remove_mapping(unsigned long start,#endif struct page *realmode_pfn_to_page (unsigned long pfn); -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -extern pmd_t pfn_pmd (unsigned long pfn,pgprot_t pgprot); -extern pmd_t mk_pmd (struct page *page,pgprot_t pgprot); -extern pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot); -extern void set_pmd_at (struct mm_struct *mm,unsigned long addr, -pmd_t *pmdp,pmd_t pmd); -extern void update_mmu_cache_pmd (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmd); -extern int has_transparent_hugepage (void ); -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ - -static inline pte_t pmd_pte (pmd_t pmd) {return __pte (pmd_val (pmd));
@@ -803,7 +791,6 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd) {return (pte_t *)pmd; } -#define pmd_pfn (pmd) pte_pfn(pmd_pte(pmd))#define pmd_dirty (pmd) pte_dirty(pmd_pte(pmd))#define pmd_young (pmd) pte_young(pmd_pte(pmd))
@@ -830,6 +817,16 @@ static inline int pmd_protnone(pmd_t pmd)#define __HAVE_ARCH_PMD_WRITE#define pmd_write (pmd) pte_write(pmd_pte(pmd)) +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +extern pmd_t pfn_pmd (unsigned long pfn,pgprot_t pgprot); +extern pmd_t mk_pmd (struct page *page,pgprot_t pgprot); +extern pmd_t pmd_modify (pmd_t pmd,pgprot_t newprot); +extern void set_pmd_at (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,pmd_t pmd); +extern void update_mmu_cache_pmd (struct vm_area_struct *vma,unsigned long addr, +pmd_t *pmd); +extern int has_transparent_hugepage (void ); +static inline pmd_t pmd_mkhuge (pmd_t pmd) {return __pmd (pmd_val (pmd) | (_PAGE_PTE |H_PAGE_THP_HUGE ));
@@ -878,5 +875,6 @@ static inline int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,*/ return true; } +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
arch/powerpc/mm/pgtable-hash64.c +360 -3
378 lines not on this page · raw message
arch/powerpc/mm/pgtable_64.c +0 -360
369 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v2 64/68 powerpc/mm/thp: Abstraction for THP functions
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/hash-64k.h | 23 +++- arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 42 +------ arch/powerpc/include/asm/book3s/64/pgtable.h | 83 +++++++++++--- arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/pgtable-book3s64.c | 123 ++++++++++++++++++++ arch/powerpc/mm/pgtable-hash64.c | 137 +++-------------------- 6 files changed, 231 insertions(+), 179 deletions(-) create mode 100644 arch/powerpc/mm/pgtable-book3s64.c
arch/powerpc/include/asm/book3s/64/hash-64k.h +18 -5
@@ -119,11 +119,6 @@ static inline int hlremap_4k_pfn(struct vm_area_struct *vma, unsigned long addr,#define H_PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)#ifdef CONFIG_TRANSPARENT_HUGEPAGE -extern unsigned long pmd_hugepage_update (struct mm_struct *mm, -unsigned long addr, -pmd_t *pmdp, -unsigned long clr, -unsigned long set);static inline char *get_hpte_slot_array (pmd_t *pmdp) {/*
@@ -193,6 +188,24 @@ static inline int hlpmd_same(pmd_t pmd_a, pmd_t pmd_b)return (((pmd_val (pmd_a) ^pmd_val (pmd_b)) & ~_PAGE_HPTEFLAGS) ==0 ); } +static inline pmd_t hlpmd_mkhuge (pmd_t pmd) +{ +return __pmd (pmd_val (pmd) | (_PAGE_PTE |H_PAGE_THP_HUGE )); +} + +extern unsigned long hlpmd_hugepage_update (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp, +unsigned long clr,unsigned long set); +extern pmd_t hlpmdp_collapse_flush (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp); +extern void hlpgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable); +extern pgtable_t hlpgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp); +extern void hlpmdp_huge_split_prepare (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp); +extern pmd_t hlpmdp_huge_get_and_clear (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp); +extern int hl_has_transparent_hugepage (void );#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif /* __ASSEMBLY__ */
arch/powerpc/include/asm/book3s/64/pgtable-64k.h +6 -36
60 lines not on this page · raw message
arch/powerpc/include/asm/book3s/64/pgtable.h +70 -13
114 lines not on this page · raw message
arch/powerpc/mm/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ obj-$(CONFIG_PPC_BOOK3E) += tlb_low_$(CONFIG_WORD_SIZE)e.o hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o -obj-$(CONFIG_PPC_STD_MMU_64) += pgtable-hash64.o hash_utils_64.o slb_low.o slb.o $(hash64-y) mmu_context_book3s64.o +obj-$(CONFIG_PPC_STD_MMU_64) += pgtable-hash64.o hash_utils_64.o slb_low.o slb.o $(hash64-y) mmu_context_book3s64.o pgtable-book3s64.o obj-$(CONFIG_PPC_RADIX_MMU) += pgtable-radix.o tlb-radix.o obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o mmu_context_hash32.o obj-$(CONFIG_PPC_STD_MMU) += tlb_hash$(CONFIG_WORD_SIZE).o
arch/powerpc/mm/pgtable-book3s64.c new file +123 -0
123 lines not on this page · raw message
arch/powerpc/mm/pgtable-hash64.c +13 -124
188 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v2 65/68 powerpc/mm/radix: Add radix THP callbacks
In reply to Aneesh Kumar K.VThe deposited pgtable_t is a pte fragment hence we cannot use page->lru for linking then together. We use the first two 64 bits for pte fragment as list_head type to link all deposited fragments together. On withdraw we properly zero then out.
--- arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 2 + arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++++ arch/powerpc/include/asm/book3s/64/radix.h | 22 +++++ arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable-radix.c | 117 +++++++++++++++++++++++ 5 files changed, 158 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/book3s/64/pgtable-64k.h +2 -0
@@ -71,6 +71,8 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)static inline pmd_t pmd_mkhuge (pmd_t pmd) { +if (radix_enabled ()) +return rpmd_mkhuge (pmd);return hlpmd_mkhuge (pmd); }
arch/powerpc/include/asm/book3s/64/pgtable.h +16 -0
@@ -827,6 +827,8 @@ extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,extern int hl_has_transparent_hugepage (void );static inline int has_transparent_hugepage (void ) { +if (radix_enabled ()) +return r_has_transparent_hugepage ();return hl_has_transparent_hugepage (); }
@@ -834,6 +836,8 @@ static inline unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, unsigned long clr, unsigned long set) { + if (radix_enabled()) + return rpmd_hugepage_update(mm, addr, pmdp, clr, set);return hlpmd_hugepage_update (mm, addr, pmdp, clr, set); }
@@ -885,12 +889,16 @@ extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,static inline pmd_t pmdp_huge_get_and_clear (struct mm_struct *mm,unsigned long addr,pmd_t *pmdp) { +if (radix_enabled ()) +return rpmdp_huge_get_and_clear (mm, addr, pmdp);return hlpmdp_huge_get_and_clear (mm, addr, pmdp); }static inline pmd_t pmdp_collapse_flush (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp) { +if (radix_enabled ()) +return rpmdp_collapse_flush (vma, address, pmdp);return hlpmdp_collapse_flush (vma, address, pmdp); }#define pmdp_collapse_flush pmdp_collapse_flush
@@ -899,6 +907,8 @@ static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,static inline void pgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp,pgtable_t pgtable) { +if (radix_enabled ()) +return rpgtable_trans_huge_deposit (mm, pmdp, pgtable);return hlpgtable_trans_huge_deposit (mm, pmdp, pgtable); }
@@ -906,6 +916,8 @@ static inline void pgtable_trans_huge_deposit(struct mm_struct *mm,static inline pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp) { +if (radix_enabled ()) +return rpgtable_trans_huge_withdraw (mm, pmdp);return hlpgtable_trans_huge_withdraw (mm, pmdp); }
@@ -917,6 +929,8 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,static inline void pmdp_huge_split_prepare (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp) { +if (radix_enabled ()) +return rpmdp_huge_split_prepare (vma, address, pmdp);return hlpmdp_huge_split_prepare (vma, address, pmdp); }
@@ -925,6 +939,8 @@ struct spinlock;static inline int pmd_move_must_withdraw (struct spinlock *new_pmd_ptl,struct spinlock *old_pmd_ptl) { +if (radix_enabled ()) +return false;/* * Archs like ppc64 use pgtable to store per pmd * specific information. So when we switch the pmd,
arch/powerpc/include/asm/book3s/64/radix.h +22 -0
@@ -152,6 +152,28 @@ static inline int rpmd_trans_huge(pmd_t pmd)return !!(pmd_val (pmd) & _PAGE_PTE); } +static inline pmd_t rpmd_mkhuge (pmd_t pmd) +{ +return __pmd (pmd_val (pmd) | _PAGE_PTE); +} +static inline void rpmdp_huge_split_prepare (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp) +{ +/* Nothing to do for radix. */ +return ; +} + +extern unsigned long rpmd_hugepage_update (struct mm_struct *mm,unsigned long addr, +pmd_t *pmdp,unsigned long clr, +unsigned long set); +extern pmd_t rpmdp_collapse_flush (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp); +extern void rpgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable); +extern pgtable_t rpgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp); +extern pmd_t rpmdp_huge_get_and_clear (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp); +extern int r_has_transparent_hugepage (void );#endif extern int __meminit rvmemmap_create_mapping(unsigned long start,
arch/powerpc/mm/pgtable-book3s64.c +1 -1
@@ -74,7 +74,7 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) {pmd_hugepage_update (vma->vm_mm, address, pmdp, _PAGE_PRESENT,0 ); - +flush_tlb_range (vma, address, address +HPAGE_PMD_SIZE );/* * This ensures that generic code that rely on IRQ disabling * to prevent a parallel THP split work as expected.
arch/powerpc/mm/pgtable-radix.c +117 -0
126 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v2 66/68 powerpc/mm/radix: Add THP support for 4k linux page size
In reply to Aneesh Kumar K.V--- arch/powerpc/include/asm/book3s/64/hash-4k.h | 59 ++++++++++++++++++++++++ arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 25 ---------- arch/powerpc/include/asm/book3s/64/pgtable.h | 22 +++++++++ arch/powerpc/platforms/Kconfig.cputype | 2 +- 4 files changed, 82 insertions(+), 26 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +59 -0
@@ -50,6 +50,65 @@ static inline int hl_hugepd_ok(hugepd_t hpd) }#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + +static inline char *get_hpte_slot_array (pmd_t *pmdp) +{ +BUG (); +return NULL ; +} + +static inline unsigned int hpte_valid (unsigned char *hpte_slot_array,int index) +{ +BUG (); +return 0 ; +} + +static inline unsigned int hpte_hash_index (unsigned char *hpte_slot_array, +int index) +{ +BUG (); +return 0 ; +} + +static inline void mark_hpte_slot_valid (unsigned char *hpte_slot_array, +unsigned int index,unsigned int hidx) +{ +BUG (); +} + +static inline int hlpmd_trans_huge (pmd_t pmd) +{ +return 0 ; +} + +static inline int hlpmd_same (pmd_t pmd_a,pmd_t pmd_b) +{ +BUG (); +return 0 ; +} + +static inline pmd_t hlpmd_mkhuge (pmd_t pmd) +{ +BUG (); +return pmd; +} + +extern unsigned long hlpmd_hugepage_update (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp, +unsigned long clr,unsigned long set); +extern pmd_t hlpmdp_collapse_flush (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp); +extern void hlpgtable_trans_huge_deposit (struct mm_struct *mm,pmd_t *pmdp, +pgtable_t pgtable); +extern pgtable_t hlpgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp); +extern void hlpmdp_huge_split_prepare (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp); +extern pmd_t hlpmdp_huge_get_and_clear (struct mm_struct *mm, +unsigned long addr,pmd_t *pmdp); +extern int hl_has_transparent_hugepage (void ); +#endif +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */
arch/powerpc/include/asm/book3s/64/pgtable-64k.h +0 -25
@@ -53,31 +53,6 @@ static inline int hugepd_ok(hugepd_t hpd)#endif /* CONFIG_HUGETLB_PAGE */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -static inline int pmd_trans_huge (pmd_t pmd) -{ -if (radix_enabled ()) -return rpmd_trans_huge (pmd); -return hlpmd_trans_huge (pmd); -} - -#define __HAVE_ARCH_PMD_SAME -static inline int pmd_same (pmd_t pmd_a,pmd_t pmd_b) -{ -if (radix_enabled ()) -return rpmd_same (pmd_a, pmd_b); -return hlpmd_same (pmd_a, pmd_b); -} - -static inline pmd_t pmd_mkhuge (pmd_t pmd) -{ -if (radix_enabled ()) -return rpmd_mkhuge (pmd); -return hlpmd_mkhuge (pmd); -} - -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline int remap_4k_pfn (struct vm_area_struct *vma,unsigned long addr,unsigned long pfn,pgprot_t prot) {
arch/powerpc/include/asm/book3s/64/pgtable.h +22 -0
@@ -876,6 +876,28 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,pmd_hugepage_update (mm, addr, pmdp, _PAGE_WRITE,0 ); } +static inline int pmd_trans_huge (pmd_t pmd) +{ +if (radix_enabled ()) +return rpmd_trans_huge (pmd); +return hlpmd_trans_huge (pmd); +} + +#define __HAVE_ARCH_PMD_SAME +static inline int pmd_same (pmd_t pmd_a,pmd_t pmd_b) +{ +if (radix_enabled ()) +return rpmd_same (pmd_a, pmd_b); +return hlpmd_same (pmd_a, pmd_b); +} + +static inline pmd_t pmd_mkhuge (pmd_t pmd) +{ +if (radix_enabled ()) +return rpmd_mkhuge (pmd); +return hlpmd_mkhuge (pmd); +} +#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS extern int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp,
arch/powerpc/platforms/Kconfig.cputype +1 -1
@@ -72,7 +72,7 @@ config PPC_BOOK3S_64 select PPC_FPU select PPC_HAVE_PMU_SUPPORT select SYS_SUPPORTS_HUGETLBFS - select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES + select HAVE_ARCH_TRANSPARENT_HUGEPAGE select ARCH_SUPPORTS_NUMA_BALANCING select IRQ_WORK
Signature · 1 line
2.5.0
Michael Ellerman
reviewerRe: [V2, 66/68] powerpc/mm/radix: Add THP support for 4k linux page size
On Sat, 2016-09-04 at 06:14:02 UTC, "Aneesh Kumar K.V" wrote:
Missing change log.
Quoted 17 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>arch/powerpc/include/asm/book3s/64/hash-4k.h +7
-0@@ -50,6 +50,65 @@ static inline int hl_hugepd_ok(hugepd_t hpd) }#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + +static inline char *get_hpte_slot_array (pmd_t *pmdp) +{ +BUG (); +return NULL ; +}
...
arch/powerpc/platforms/Kconfig.cputype config PPC_BOOK3S_64 · line 75
Quoted 10 lines
arch/powerpc/platforms/Kconfig.cputype +1
-1@@ -72,7 +72,7 @@ config PPC_BOOK3S_64 select PPC_FPU select PPC_HAVE_PMU_SUPPORT select SYS_SUPPORTS_HUGETLBFS - select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES + select HAVE_ARCH_TRANSPARENT_HUGEPAGE
How is this meant to work?
It appears to allow me to build a 4K kernel with THP which will then BUG() as soon as I run it on hash?
I assume you'll tell me there's some mechanism somewhere that prevents that from happening, but what is it?
cheers
Re: [V2, 66/68] powerpc/mm/radix: Add THP support for 4k linux page size
Quoted 3 lines · Michael Ellerman
On Sat, 2016-09-04 at 06:14:02 UTC, "Aneesh Kumar K.V" wrote:
Missing change log.
This add THP support for 4K linux page size config with Radix. We still don't do THP with 4K linux page size and hash page table. Hash page table needs a 16MB hugepage and we can't do THP with 16MM hugepage and 4K linux page size.
We add missing functions to 4k hash config to get it build and hl_has_transparent_hugepage() make sure we don't enable THP for 4K hash config. To catch wrong usage of THP related with 4K config, we add BUG() in those dummpy functions we added to get it compile.
Quoted 35 lines
Quoted 18 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>arch/powerpc/include/asm/book3s/64/hash-4k.h +7
-0@@ -50,6 +50,65 @@ static inline int hl_hugepd_ok(hugepd_t hpd) }#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + +static inline char *get_hpte_slot_array (pmd_t *pmdp) +{ +BUG (); +return NULL ; +}...
arch/powerpc/platforms/Kconfig.cputype config PPC_BOOK3S_64 · line 75
Quoted 10 lines
arch/powerpc/platforms/Kconfig.cputype +1
-1@@ -72,7 +72,7 @@ config PPC_BOOK3S_64 select PPC_FPU select PPC_HAVE_PMU_SUPPORT select SYS_SUPPORTS_HUGETLBFS - select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES + select HAVE_ARCH_TRANSPARENT_HUGEPAGEHow is this meant to work?
Quoted 6 lines
It appears to allow me to build a 4K kernel with THP which will then
BUG()as soon as I run it on hash?I assume you'll tell me there's some mechanism somewhere that prevents that from happening, but what is it?
This one.
int hl_has_transparent_hugepage(void)
{
if (!mmu_has_feature(MMU_FTR_16M_PAGE)) return 0; /* * We support THP only if PMD_SIZE is 16MB. */ if (mmu_psize_defs[MMU_PAGE_16M].shift != PMD_SHIFT) return 0; /* * We need to make sure that we support 16MB hugepage in a segement * with base page size 64K or 4K. We only enable THP with a PAGE_SIZE * of 64K. */ /* * If we have 64K HPTE, we will be using that by default */ if (mmu_psize_defs[MMU_PAGE_64K].shift && (mmu_psize_defs[MMU_PAGE_64K].penc[MMU_PAGE_16M] == -1)) return 0; /* * Ok we only have 4K HPTE */ if (mmu_psize_defs[MMU_PAGE_4K].penc[MMU_PAGE_16M] == -1) return 0; return 1; }
So we will enable THP on a platform only if has_transparent_hugepage() return 1.
-aneesh
PATCH v2 67/68 powerpc/mm/radix: Cputable update for radix
In reply to Aneesh Kumar K.VWith P9 Radix we need to do
* set UPRT = 1
* set different TLB set count
In this patch we delay the UPRT=1 to early mmu init. This help us to keep the cpu table setup and restore cpu callback the same across different MMU model.
This also implies that a cpu_restore cur_cpu_spec callback won't set UPRT=1. We currently use that for secondary cpu init and on primary after we did an opal reinit for endian switch. In both the case we call early_mmu_init after the above operations. This set UPRT to correct value.
--- arch/powerpc/include/asm/reg.h | 4 ++++ arch/powerpc/kernel/cputable.c | 2 +- arch/powerpc/kernel/mce_power.c | 3 ++- arch/powerpc/mm/pgtable-radix.c | 13 +++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/reg.h +4 -0
@@ -347,6 +347,10 @@#define LPCR_LPES_SH 2#define LPCR_RMI 0x00000002/* real mode is cache inhibit */ #define LPCR_HDICE 0x00000001/* Hyp Decr enable (HV,PR,EE) */ +/* +* Used in asm code, hence we don't want to use PPC_BITCOUNT +*/ +#define LPCR_UPRT (ASM_CONST(0x1) << 22)#ifndef SPRN_LPID #define SPRN_LPID 0x13F/* Logical Partition Identifier */ #endif
arch/powerpc/kernel/cputable.c +1 -1
@@ -514,7 +514,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_POWER9, .cpu_user_features = COMMON_USER_POWER9, .cpu_user_features2 = COMMON_USER2_POWER9, - .mmu_features = MMU_FTRS_POWER9, + .mmu_features = MMU_FTRS_POWER9 | MMU_FTR_RADIX, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 6,
arch/powerpc/kernel/mce_power.c +2 -1
@@ -72,10 +72,11 @@ void __flush_tlb_power8(unsigned int action)void __flush_tlb_power9 (unsigned int action) { +if (radix_enabled ()) +flush_tlb_206 (POWER9_TLB_SETS_RADIX , action);flush_tlb_206 (POWER9_TLB_SETS_HASH , action); } -/* flush SLBs and reload */ #ifdef CONFIG_PPC_MMU_STD_64 static void flush_and_reload_slb (void )
arch/powerpc/mm/pgtable-radix.c +13 -0
@@ -296,6 +296,13 @@ found:void __init rearly_init_mmu (void ) { +unsigned long lpcr; +/* +* setup LPCR UPRT based on mmu_features +*/ + lpcr =mfspr (SPRN_LPCR ); +mtspr (SPRN_LPCR , lpcr |LPCR_UPRT ); +#ifdef CONFIG_PPC_64K_PAGES /* PAGE_SIZE mappings */ mmu_virtual_psize =MMU_PAGE_64K ;
@@ -345,6 +352,12 @@ void __init rearly_init_mmu(void)void rearly_init_mmu_secondary (void ) { +unsigned long lpcr; +/* +* setup LPCR UPRT based on mmu_features +*/ + lpcr =mfspr (SPRN_LPCR ); +mtspr (SPRN_LPCR , lpcr |LPCR_UPRT );/* * update partition table control register, 64 K size. */
Signature · 1 line
2.5.0
Michael Ellerman
reviewerRe: [V2,67/68] powerpc/mm/radix: Cputable update for radix
Quoted 9 lines · Aneesh Kumar K.V
With P9 Radix we need to do
* set UPRT = 1
* set different TLB set countIn this patch we delay the UPRT=1 to early mmu init. This help us to keep the cpu table setup and restore cpu callback the same across different MMU model.
Quoted 5 lines
This also implies that a
cpu_restorecur_cpu_speccallback won't set UPRT=1. We currently use that for secondary cpu init and on primary after we did an opal reinit for endian switch. In both the case we callearly_mmu_initafter the above operations. This set UPRT to correct value.
This probably needs a new subject and updated change log as it is mainly adding the setup code.
arch/powerpc/kernel/cputable.c static struct cpu_spec __initdata cpu_specs[] = { · line 517
Quoted 10 lines
arch/powerpc/kernel/cputable.c +1
-1@@ -514,7 +514,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_POWER9, .cpu_user_features = COMMON_USER_POWER9, .cpu_user_features2 = COMMON_USER2_POWER9, - .mmu_features = MMU_FTRS_POWER9, + .mmu_features = MMU_FTRS_POWER9 | MMU_FTR_RADIX,
I think we discussed this before, but I want to drop this.
That will mean the only way MMU_FTR_RADIX is enabled is via ibm,pa-features (in the next patch).
cheers
PATCH v2 68/68 powerpc/mm/radix: Use firmware feature to disable radix
In reply to Aneesh Kumar K.VWe can depend on ibm,pa-features to enable/disable radix. This gives us a nice way to test p9 hash config, by changing device tree property.
--- arch/powerpc/kernel/prom.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/prom.c +1 -0
@@ -165,6 +165,7 @@ static struct ibm_pa_feature {* which is 0 if the kernel doesn't support TM. */ {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0}, + {0, MMU_FTR_RADIX, 0, 40, 0, 0}, }; static void __init scan_features(unsigned long node, const unsigned char *ftrs,
Signature · 1 line
2.5.0
Michael Ellerman
reviewerRe: [V2, 68/68] powerpc/mm/radix: Use firmware feature to disable radix
Quoted 2 lines · Aneesh Kumar K.V
We can depend on ibm,pa-features to enable/disable radix. This gives us a nice way to test p9 hash config, by changing device tree property.
I think we might want to be more careful here.
You set MMU_FTR_RADIX in the cputable entry. So it's on by default on P9 cpus.
Then if there is an ibm,pa-features property *and* it is >= 41 bytes long, the below feature entry will hit. In that case the firmware controls whether it's on or off.
I think it would be clearer if we removed RADIX from the cputable, and the below became the only way to turn it on. Would that break anything?
arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168
Quoted 9 lines
arch/powerpc/kernel/prom.c +1
-0@@ -165,6 +165,7 @@ static struct ibm_pa_feature {* which is 0 if the kernel doesn't support TM. */ {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0}, + {0, MMU_FTR_RADIX, 0, 40, 0, 0},
So that says bit 0 of byte 40 enables MMU_FTR_RADIX. Where is that documented?
cheers
Re: [V2, 68/68] powerpc/mm/radix: Use firmware feature to disable radix
Quoted 6 lines · Michael Ellerman
Quoted 2 lines · Aneesh Kumar K.V
We can depend on ibm,pa-features to enable/disable radix. This gives us a nice way to test p9 hash config, by changing device tree property.
I think we might want to be more careful here.
Quoted 8 lines
You set
MMU_FTR_RADIXin the cputable entry. So it's on by default on P9 cpus.Then if there is an ibm,pa-features property *and* it is >= 41 bytes long, the below feature entry will hit. In that case the firmware controls whether it's on or off.
I think it would be clearer if we removed RADIX from the cputable, and the below became the only way to turn it on. Would that break anything?
I was thinking we want to use RADIX by default on Power9. Hence the idea of clearing feature bit. Now we will be using this to switch between Radix and hash segment table. We are not really going to use this to switch between the long tested SLB hash to the newly added Power9 Radix. So it is not really there to make sure we run safely with old code by default.
Quoted 13 lines
arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168
Quoted 10 lines
arch/powerpc/kernel/prom.c +1
-0@@ -165,6 +165,7 @@ static struct ibm_pa_feature {* which is 0 if the kernel doesn't support TM. */ {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0}, + {0, MMU_FTR_RADIX, 0, 40, 0, 0},So that says bit 0 of byte 40 enables
MMU_FTR_RADIX. Where is that documented?
In PAPR document.
-aneehs
Re: [V2, 68/68] powerpc/mm/radix: Use firmware feature to disable radix
In reply to Michael EllermanQuoted 8 lines · Michael Ellerman
Quoted 2 lines · Aneesh Kumar K.V
We can depend on ibm,pa-features to enable/disable radix. This gives us a nice way to test p9 hash config, by changing device tree property.
=20
I think we might want to be more careful here.
=20
You setMMU_FTR_RADIXin the cputable entry. So it's on by default on P9 =
cpus.
Quoted 2 lines
=20
Then if there is an ibm,pa-features property *and* it is >=3D 41 bytes lo=
ng, the
Quoted 1 line
below feature entry will hit. In that case the firmware controls whether =
it's on
Quoted 3 lines
or off.
=20
I think it would be clearer if we removed RADIX from the cputable, and th=
e below
Quoted 1 line
became the only way to turn it on. Would that break anything?
I don't think it'll break anything. FWIW I'm good with this approach.
We'll need to teach firmware about this feature, but I think we should do that anyway. skiboot is a bit of a mess WRT to this property with HDAT vs device tree, but we can clean that up there.
Mikey
Quoted 13 lines
=20
arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168
Quoted 9 lines
arch/powerpc/kernel/prom.c +1
-0@@ -165,6 +165,7 @@ static struct ibm_pa_feature {* which is 0 if the kernel doesn't support TM. */ {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0}, + {0, MMU_FTR_RADIX, 0, 40, 0, 0},=20
So that says bit 0 of byte 40 enablesMMU_FTR_RADIX. Where is that docume=
nted?
Quoted 6 lines
=20
cheers
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev