Skip to contentSkip to conversation

powerpc/64s: free page table caches at exit_mmap time

PATCH Applied Nicholas Piggin 3 participants 3 messages Jul 25, 2018 – Aug 8, 2018 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s: free page table caches at exit_mmap time

The kernel page table caches are tied to init_mm, so there is no more need for them after userspace is finished.

---
 arch/powerpc/mm/mmu_context_book3s64.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/mm/mmu_context_book3s64.c +3 -2
index 3bb5cec03d1f..5738c2db751c 100644
@@ -221,7 +221,7 @@ static void pmd_frag_destroy(void *pmd_frag)
 	}
 }
 
-static void destroy_pagetable_page(struct mm_struct *mm)
+static void destroy_pagetable_cache(struct mm_struct *mm)
 {
 	void *frag;
 
@@ -244,13 +244,14 @@ void destroy_context(struct mm_struct *mm)
 		WARN_ON(process_tb[mm->context.id].prtb0 != 0);
 	else
 		subpage_prot_free(mm);
-	destroy_pagetable_page(mm);
 	destroy_contexts(&mm->context);
 	mm->context.id = MMU_NO_CONTEXT;
 }
 
 void arch_exit_mmap(struct mm_struct *mm)
 {
+	destroy_pagetable_cache(mm);
+
 	if (radix_enabled()) {
 		/*
 		 * Radix doesn't have a valid bit in the process table
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Nicholas Piggin

The kernel page table caches are tied to init_mm, so there is no more need for them after userspace is finished.

The commit message could be improved with reference to active_mm.

something like?

destroy_context get called when we drop the last reference for mm which could be much later than the task exit due to other lazy mm reference to it. We could free the page table cache pages on task exit because they only cache the userspace page table and kernel thread should not access the user space address.

The mapping for kernel threads itself is maintained in init_mm and page table cache for that is attached to init_mm

Quoted 36 lines
---
 arch/powerpc/mm/mmu_context_book3s64.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/mm/mmu_context_book3s64.c +3 -2
index 3bb5cec03d1f..5738c2db751c 100644
@@ -221,7 +221,7 @@ static void pmd_frag_destroy(void *pmd_frag)
 	}
 }
 
-static void destroy_pagetable_page(struct mm_struct *mm)
+static void destroy_pagetable_cache(struct mm_struct *mm)
 {
 	void *frag;
 
@@ -244,13 +244,14 @@ void destroy_context(struct mm_struct *mm)
 		WARN_ON(process_tb[mm->context.id].prtb0 != 0);
 	else
 		subpage_prot_free(mm);
-	destroy_pagetable_page(mm);
 	destroy_contexts(&mm->context);
 	mm->context.id = MMU_NO_CONTEXT;
 }
 
 void arch_exit_mmap(struct mm_struct *mm)
 {
+	destroy_pagetable_cache(mm);
+
 	if (radix_enabled()) {
 		/*
 		 * Radix doesn't have a valid bit in the process table
Signature · 1 line
2.17.0