Skip to content

Commit

Permalink
powerpc/64s: free page table caches at exit_mmap time
Browse files Browse the repository at this point in the history
The kernel page table caches are tied to init_mm, so there is no
more need for them after userspace is finished.

destroy_context() gets called when we drop the last reference for an
mm, which can be much later than the task exit due to other lazy mm
references to it. We can free the page table cache pages on task exit
because they only cache the userspace page tables and kernel threads
should not access user space addresses.

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

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
[mpe: Merge change log additions from Aneesh]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Nicholas Piggin authored and Michael Ellerman committed Aug 7, 2018
1 parent 5a60993 commit 34c604d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/powerpc/mm/mmu_context_book3s64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit 34c604d

Please sign in to comment.