sparc64: Eliminate PTE table memory wastage.
David Miller
maintainerPATCH 3/7 sparc64: Eliminate PTE table memory wastage.
We've split up the PTE tables so that they take up half a page instead of a full page. This is in order to facilitate transparent huge page support, which works much better if our PMDs cover 4MB instead of 8MB.
What we do is have a one-behind cache for PTE table allocations in the mm struct.
This logic triggers only on allocations. For example, we don't try to keep track of free'd up page table blocks in the style that the s390 port does.
There were only two slightly annoying aspects to this change:
1) Changing pgtable_t to be a "pte_t *". There's all of this special logic in the TLB free paths that needed adjustments, as did the PMD populate interfaces.
2) init_new_context() needs to zap the pointer, since the mm struct just gets copied from the parent on fork.
--- arch/sparc/include/asm/mmu_64.h | 1 + arch/sparc/include/asm/page_64.h | 2 +- arch/sparc/include/asm/pgalloc_64.h | 54 ++++--------------- arch/sparc/mm/init_64.c | 101 +++++++++++++++++++++++++++++++++++ arch/sparc/mm/tsb.c | 9 ++++ 5 files changed, 123 insertions(+), 44 deletions(-)
arch/sparc/include/asm/mmu_64.h +1 -0
@@ -93,6 +93,7 @@ typedef struct {spinlock_t lock;unsigned long sparc64_ctx_val;unsigned long huge_pte_count; +struct page *pgtable_page;struct tsb_config tsb_block[MM_NUM_TSBS ];struct hv_tsb_descr tsb_descr[MM_NUM_TSBS ]; } mm_context_t;
arch/sparc/include/asm/page_64.h +1 -1
@@ -86,7 +86,7 @@ typedef unsigned long pgprot_t;#endif /* (STRICT_MM_TYPECHECKS) */ -typedef struct page *pgtable_t ; +typedef pte_t *pgtable_t ;#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ (_AC(0x0000000070000000,UL)) : \
arch/sparc/include/asm/pgalloc_64.h +11 -43
73 lines not on this page · raw message
arch/sparc/mm/init_64.c +101 -0
104 lines not on this page · raw message
arch/sparc/mm/tsb.c +9 -0
@@ -445,6 +445,8 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) mm->context.huge_pte_count =0 ;#endif + mm->context.pgtable_page =NULL ; +/* copy_mm() copies over the parent's mm_struct before calling * us, so we need to zero out the TSB pointer or else tsb_grow() * will be confused and think there is an older TSB to free up.
@@ -483,10 +485,17 @@ static void tsb_destroy_one(struct tsb_config *tp)void destroy_context (struct mm_struct *mm) {unsigned long flags, i; +struct page *page;for (i =0 ; i <MM_NUM_TSBS ; i++)tsb_destroy_one (&mm->context.tsb_block[i]); + page = mm->context.pgtable_page; +if (page &&put_page_testzero (page)) { +pgtable_page_dtor (page); +free_hot_cold_page (page,0 ); + } +spin_lock_irqsave (&ctx_alloc_lock, flags);if (CTX_VALID (mm->context)) {
Signature · 1 line
1.7.10.4