powerpc: Add support for multiple PTE page fragment in PTE page
RFC PATCH 1/3 powerpc: Don't hard code the size of pte page
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
USE PTRS_PER_PTE to indicate the size of pte page.
--- arch/powerpc/include/asm/pgtable.h | 6 ++++++ arch/powerpc/mm/hash_low_64.S | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/pgtable.h +6 -0
@@ -17,6 +17,12 @@ struct mm_struct;# include <asm/pgtable-ppc32.h> #endif +/* +* hidx is in the second half of the page table. We use the +* 8 bytes per each pte entry. +*/ +#define PTE_PAGE_HIDX_OFFSET (PTRS_PER_PTE * 8) +#ifndef __ASSEMBLY__#include <asm/tlbflush.h>
arch/powerpc/mm/hash_low_64.S +2 -2
@@ -484,7 +484,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE) beq htab_inval_old_hpte ld r6,STK_PARAM(R6)(r1) - ori r26,r6,0x8000 /* Load the hidx mask */ + ori r26,r6,PTE_PAGE_HIDX_OFFSET /* Load the hidx mask. */ ld r26,0(r26) addi r5,r25,36 /* Check actual HPTE_SUB bit, this */ rldcr. r0,r31,r5,0 /* must match pgtable.h definition */
@@ -601,7 +601,7 @@ htab_pte_insert_ok: sld r4,r4,r5 andc r26,r26,r4 or r26,r26,r3 - ori r5,r6,0x8000 + ori r5,r6,PTE_PAGE_HIDX_OFFSET std r26,0(r5) lwsync std r30,0(r6)
Signature · 1 line
1.7.10
RFC PATCH 3/3 powerpc: Reduce PTE table memory wastage
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
We now have PTE page consuming only 2K of the 64K page.This is in order to facilitate transparent huge page support, which works much better if our PMDs cover 16MB instead of 256MB.
Inorder to reduce the wastage, we now have multiple PTE page fragment from the same PTE page.
--- arch/powerpc/include/asm/mmu-book3e.h | 4 + arch/powerpc/include/asm/mmu-hash64.h | 4 + arch/powerpc/include/asm/page.h | 4 + arch/powerpc/include/asm/pgalloc-32.h | 45 ++++++++ arch/powerpc/include/asm/pgalloc-64.h | 143 ++++++++++++++++++++----- arch/powerpc/include/asm/pgalloc.h | 46 +------- arch/powerpc/kernel/setup_64.c | 4 +- arch/powerpc/mm/mmu_context_hash64.c | 12 +++ arch/powerpc/mm/pgtable_64.c | 189 +++++++++++++++++++++++++++++++++ 9 files changed, 377 insertions(+), 74 deletions(-)
arch/powerpc/include/asm/mmu-book3e.h +4 -0
@@ -231,6 +231,10 @@ typedef struct {u64 high_slices_psize;/* 4 bits per slice for now */ u16 user_psize;/* page size index */ #endif +#ifdef CONFIG_PPC_64K_PAGES +/* for 2K page table support */ +struct list_head pgtable_list; +#endif } mm_context_t;/* Page size definitions, common between 32 and 64-bit
arch/powerpc/include/asm/mmu-hash64.h +4 -0
@@ -480,6 +480,10 @@ typedef struct {unsigned long acop;/* mask of enabled coprocessor types */ unsigned int cop_pid;/* pid value used with coprocessors */ #endif /* CONFIG_PPC_ICSWX */ +#ifdef CONFIG_PPC_64K_PAGES +/* for 2K page table support */ +struct list_head pgtable_list; +#endif } mm_context_t;
arch/powerpc/include/asm/page.h +4 -0
@@ -378,7 +378,11 @@ void arch_free_page(struct page *page, int order);struct vm_area_struct ; +#ifdef CONFIG_PPC_64K_PAGES +typedef pte_t *pgtable_t ; +#else typedef struct page *pgtable_t ; +#endif #include <asm-generic/memory_model.h> #endif /* __ASSEMBLY__ */
arch/powerpc/include/asm/pgalloc-32.h +45 -0
55 lines not on this page · raw message
arch/powerpc/include/asm/pgalloc-64.h +115 -28
175 lines not on this page · raw message
arch/powerpc/include/asm/pgalloc.h +1 -45
63 lines not on this page · raw message
arch/powerpc/kernel/setup_64.c +3 -1
@@ -575,7 +575,9 @@ void __init setup_arch(char **cmdline_p) init_mm.end_code = (unsigned long ) _etext; init_mm.end_data = (unsigned long ) _edata; init_mm.brk = klimit; - +#ifdef CONFIG_PPC_64K_PAGES +INIT_LIST_HEAD (&init_mm.context.pgtable_list); +#endif irqstack_early_init ();exc_lvl_early_init ();emergency_stack_init ();
arch/powerpc/mm/mmu_context_hash64.c +12 -0
@@ -94,6 +94,8 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)spin_lock_init (mm->context.cop_lockp);#endif /* CONFIG_PPC_ICSWX */ +INIT_LIST_HEAD (&mm->context.pgtable_list); +return 0 ; }
@@ -107,11 +109,21 @@ EXPORT_SYMBOL_GPL(__destroy_context);void destroy_context (struct mm_struct *mm) { +struct page *page; +struct list_head *item, *tmp; +#ifdef CONFIG_PPC_ICSWX drop_cop (mm->context.acop, mm);kfree (mm->context.cop_lockp); mm->context.cop_lockp =NULL ;#endif /* CONFIG_PPC_ICSWX */ +list_for_each_safe (item, tmp, &mm->context.pgtable_list) { + page = list_entry(item, struct page, lru); +list_del (&page->lru); +pgtable_page_dtor (page); +atomic_set (&page->_mapcount,-1 ); +__free_page (page); + }__destroy_context (mm->context.id);subpage_prot_free (mm); mm->context.id =MMU_NO_CONTEXT ;
arch/powerpc/mm/pgtable_64.c +189 -0
198 lines not on this page · raw message
Signature · 1 line
1.7.10
RFC PATCH 1/3 powerpc: Add support for multiple PTE page fragment in PTE page
Hello,
This is the preparatory patchset for supporting THP on powerpc. I am sending this across so that we can get review on this change.
For full THP support on powerpc, I have an early version that boots and runs few test. But I am still running into few issues, like Firmware NMI etc. Once those are resolved, I will clean them up and send the complete patchset.
IMHO we should NOT be merging this patchset until we have the full THP patchset on the list. But still it will be nice to get review on the multiple PTE page fragment change. Other architectures like s390 and sparc do support something similar. The implementation here closely follows the s390 implementation.
-aneesh
RFC PATCH 2/3 arch/powerpc: Reduce the PTE_INDEX_SIZE
From: "Aneesh Kumar K.V" <[email protected]>
This make one PMD cover 16MB range. That helps in easier implementation of THP on power. THP core code make use of one pmd entry to track the huge page and the range mapped by a single pmd entry should be equal to the huge page size supported by the hardware.
--- arch/powerpc/include/asm/pgtable-ppc64-64k.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/pgtable-ppc64-64k.h +2 -2
@@ -4,10 +4,10 @@#include <asm-generic/pgtable-nopud.h> -#define PTE_INDEX_SIZE 12 +#define PTE_INDEX_SIZE 8#define PMD_INDEX_SIZE 12#define PUD_INDEX_SIZE 0 -#define PGD_INDEX_SIZE 6 +#define PGD_INDEX_SIZE 10#ifndef __ASSEMBLY__#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE)
Signature · 1 line
1.7.10