linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/64s: free page table caches at exit_mmap time
@ 2018-07-25  9:54 Nicholas Piggin
  2018-07-25 12:47 ` Aneesh Kumar K.V
  2018-08-08 14:25 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Piggin @ 2018-07-25  9:54 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Aneesh Kumar K . V

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

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/mm/mmu_context_book3s64.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index 3bb5cec03d1f..5738c2db751c 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -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
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/64s: free page table caches at exit_mmap time
  2018-07-25  9:54 [PATCH] powerpc/64s: free page table caches at exit_mmap time Nicholas Piggin
@ 2018-07-25 12:47 ` Aneesh Kumar K.V
  2018-08-08 14:25 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2018-07-25 12:47 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Aneesh Kumar K . V, Nicholas Piggin

Nicholas Piggin <npiggin@gmail.com> writes:

> 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

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/mm/mmu_context_book3s64.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
> index 3bb5cec03d1f..5738c2db751c 100644
> --- a/arch/powerpc/mm/mmu_context_book3s64.c
> +++ b/arch/powerpc/mm/mmu_context_book3s64.c
> @@ -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
> -- 
> 2.17.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc/64s: free page table caches at exit_mmap time
  2018-07-25  9:54 [PATCH] powerpc/64s: free page table caches at exit_mmap time Nicholas Piggin
  2018-07-25 12:47 ` Aneesh Kumar K.V
@ 2018-08-08 14:25 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-08-08 14:25 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Aneesh Kumar K . V, Nicholas Piggin

On Wed, 2018-07-25 at 09:54:28 UTC, Nicholas Piggin wrote:
> The kernel page table caches are tied to init_mm, so there is no
> more need for them after userspace is finished.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/34c604d27590fdc9a2c944be8c50ae

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-08 14:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25  9:54 [PATCH] powerpc/64s: free page table caches at exit_mmap time Nicholas Piggin
2018-07-25 12:47 ` Aneesh Kumar K.V
2018-08-08 14:25 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).