linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] powerpc/64s/radix: misc tidying
@ 2023-02-03 11:17 Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush Nicholas Piggin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nicholas Piggin @ 2023-02-03 11:17 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Here's a few things I wanted to tidy before doing the lazy tlb mm
shootdown / exit TLB flush IPI optimisation. There is no hard
dependency just slight code rearrangement but since we're waiting
for the shootdown patches to go via the -mm tree we could do these
now.

It basically just removing a bunch of dead code, or replacing them
with WARN so we can remove them entirely in a release or two.

Thanks,
Nick

Nicholas Piggin (3):
  powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush
  powerpc/64s/radix: mm->context.id should always be valid
  powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes

 arch/powerpc/mm/book3s64/radix_tlb.c | 62 ++++++++++++++--------------
 1 file changed, 32 insertions(+), 30 deletions(-)

-- 
2.37.2


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

* [PATCH 1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush
  2023-02-03 11:17 [PATCH 0/3] powerpc/64s/radix: misc tidying Nicholas Piggin
@ 2023-02-03 11:17 ` Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 2/3] powerpc/64s/radix: mm->context.id should always be valid Nicholas Piggin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2023-02-03 11:17 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

need_flush_all is only set by arch code to instruct generic tlb_flush
to flush all. It is never set by powerpc, so it can be removed.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/mm/book3s64/radix_tlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
index 282359ab525b..1e451184cba4 100644
--- a/arch/powerpc/mm/book3s64/radix_tlb.c
+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
@@ -1302,7 +1302,7 @@ void radix__tlb_flush(struct mmu_gather *tlb)
 	 * that flushes the process table entry cache upon process teardown.
 	 * See the comment for radix in arch_exit_mmap().
 	 */
-	if (tlb->fullmm || tlb->need_flush_all) {
+	if (tlb->fullmm) {
 		__flush_all_mm(mm, true);
 	} else if ( (psize = radix_get_mmu_psize(page_size)) == -1) {
 		if (!tlb->freed_tables)
-- 
2.37.2


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

* [PATCH 2/3] powerpc/64s/radix: mm->context.id should always be valid
  2023-02-03 11:17 [PATCH 0/3] powerpc/64s/radix: misc tidying Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush Nicholas Piggin
@ 2023-02-03 11:17 ` Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 3/3] powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes Nicholas Piggin
  2023-02-15 12:40 ` [PATCH 0/3] powerpc/64s/radix: misc tidying Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2023-02-03 11:17 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

The MMU_NO_CONTEXT checks are an unnecessary complication. Make
these warn to prepare to remove them in future.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/mm/book3s64/radix_tlb.c | 39 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
index 1e451184cba4..27aa5b0fbb3f 100644
--- a/arch/powerpc/mm/book3s64/radix_tlb.c
+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
@@ -700,12 +700,13 @@ static inline void _tlbiel_va_range_multicast(struct mm_struct *mm,
  */
 void radix__local_flush_tlb_mm(struct mm_struct *mm)
 {
-	unsigned long pid;
+	unsigned long pid = mm->context.id;
+
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
+		return;
 
 	preempt_disable();
-	pid = mm->context.id;
-	if (pid != MMU_NO_CONTEXT)
-		_tlbiel_pid(pid, RIC_FLUSH_TLB);
+	_tlbiel_pid(pid, RIC_FLUSH_TLB);
 	preempt_enable();
 }
 EXPORT_SYMBOL(radix__local_flush_tlb_mm);
@@ -713,12 +714,13 @@ EXPORT_SYMBOL(radix__local_flush_tlb_mm);
 #ifndef CONFIG_SMP
 void radix__local_flush_all_mm(struct mm_struct *mm)
 {
-	unsigned long pid;
+	unsigned long pid = mm->context.id;
+
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
+		return;
 
 	preempt_disable();
-	pid = mm->context.id;
-	if (pid != MMU_NO_CONTEXT)
-		_tlbiel_pid(pid, RIC_FLUSH_ALL);
+	_tlbiel_pid(pid, RIC_FLUSH_ALL);
 	preempt_enable();
 }
 EXPORT_SYMBOL(radix__local_flush_all_mm);
@@ -732,12 +734,13 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm)
 void radix__local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
 				       int psize)
 {
-	unsigned long pid;
+	unsigned long pid = mm->context.id;
+
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
+		return;
 
 	preempt_disable();
-	pid = mm->context.id;
-	if (pid != MMU_NO_CONTEXT)
-		_tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
+	_tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
 	preempt_enable();
 }
 
@@ -945,7 +948,7 @@ void radix__flush_tlb_mm(struct mm_struct *mm)
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	preempt_disable();
@@ -985,7 +988,7 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm)
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	preempt_disable();
@@ -1024,7 +1027,7 @@ void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	preempt_disable();
@@ -1130,7 +1133,7 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	preempt_disable();
@@ -1330,7 +1333,7 @@ static void __radix__flush_tlb_range_psize(struct mm_struct *mm,
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	fullmm = (end == TLB_FLUSH_ALL);
@@ -1406,7 +1409,7 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
 	enum tlb_flush_type type;
 
 	pid = mm->context.id;
-	if (unlikely(pid == MMU_NO_CONTEXT))
+	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
 	/* 4k page size, just blow the world */
-- 
2.37.2


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

* [PATCH 3/3] powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes
  2023-02-03 11:17 [PATCH 0/3] powerpc/64s/radix: misc tidying Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush Nicholas Piggin
  2023-02-03 11:17 ` [PATCH 2/3] powerpc/64s/radix: mm->context.id should always be valid Nicholas Piggin
@ 2023-02-03 11:17 ` Nicholas Piggin
  2023-02-15 12:40 ` [PATCH 0/3] powerpc/64s/radix: misc tidying Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2023-02-03 11:17 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

This looks like it came across from x86, but x86 uses TLB_FLUSH_ALL as
a parameter to internal functions. Powerpc never sets it anywhere.

Remove the associated logic and leave a warning for now.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/mm/book3s64/radix_tlb.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
index 27aa5b0fbb3f..2608ff7cf62c 100644
--- a/arch/powerpc/mm/book3s64/radix_tlb.c
+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
@@ -1107,6 +1107,9 @@ void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end)
 }
 EXPORT_SYMBOL(radix__flush_tlb_kernel_range);
 
+/*
+ * Doesn't appear to be used anywhere. Remove.
+ */
 #define TLB_FLUSH_ALL -1UL
 
 /*
@@ -1128,7 +1131,6 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 	unsigned int page_shift = mmu_psize_defs[mmu_virtual_psize].shift;
 	unsigned long page_size = 1UL << page_shift;
 	unsigned long nr_pages = (end - start) >> page_shift;
-	bool fullmm = (end == TLB_FLUSH_ALL);
 	bool flush_pid, flush_pwc = false;
 	enum tlb_flush_type type;
 
@@ -1136,15 +1138,15 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
 	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
+	WARN_ON_ONCE(end == TLB_FLUSH_ALL);
+
 	preempt_disable();
 	smp_mb(); /* see radix__flush_tlb_mm */
-	type = flush_type_needed(mm, fullmm);
+	type = flush_type_needed(mm, false);
 	if (type == FLUSH_TYPE_NONE)
 		goto out;
 
-	if (fullmm)
-		flush_pid = true;
-	else if (type == FLUSH_TYPE_GLOBAL)
+	if (type == FLUSH_TYPE_GLOBAL)
 		flush_pid = nr_pages > tlb_single_page_flush_ceiling;
 	else
 		flush_pid = nr_pages > tlb_local_single_page_flush_ceiling;
@@ -1328,7 +1330,6 @@ static void __radix__flush_tlb_range_psize(struct mm_struct *mm,
 	unsigned int page_shift = mmu_psize_defs[psize].shift;
 	unsigned long page_size = 1UL << page_shift;
 	unsigned long nr_pages = (end - start) >> page_shift;
-	bool fullmm = (end == TLB_FLUSH_ALL);
 	bool flush_pid;
 	enum tlb_flush_type type;
 
@@ -1336,17 +1337,15 @@ static void __radix__flush_tlb_range_psize(struct mm_struct *mm,
 	if (WARN_ON_ONCE(pid == MMU_NO_CONTEXT))
 		return;
 
-	fullmm = (end == TLB_FLUSH_ALL);
+	WARN_ON_ONCE(end == TLB_FLUSH_ALL);
 
 	preempt_disable();
 	smp_mb(); /* see radix__flush_tlb_mm */
-	type = flush_type_needed(mm, fullmm);
+	type = flush_type_needed(mm, false);
 	if (type == FLUSH_TYPE_NONE)
 		goto out;
 
-	if (fullmm)
-		flush_pid = true;
-	else if (type == FLUSH_TYPE_GLOBAL)
+	if (type == FLUSH_TYPE_GLOBAL)
 		flush_pid = nr_pages > tlb_single_page_flush_ceiling;
 	else
 		flush_pid = nr_pages > tlb_local_single_page_flush_ceiling;
-- 
2.37.2


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

* Re: [PATCH 0/3] powerpc/64s/radix: misc tidying
  2023-02-03 11:17 [PATCH 0/3] powerpc/64s/radix: misc tidying Nicholas Piggin
                   ` (2 preceding siblings ...)
  2023-02-03 11:17 ` [PATCH 3/3] powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes Nicholas Piggin
@ 2023-02-15 12:40 ` Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2023-02-15 12:40 UTC (permalink / raw)
  To: linuxppc-dev, Nicholas Piggin

On Fri, 3 Feb 2023 21:17:15 +1000, Nicholas Piggin wrote:
> Here's a few things I wanted to tidy before doing the lazy tlb mm
> shootdown / exit TLB flush IPI optimisation. There is no hard
> dependency just slight code rearrangement but since we're waiting
> for the shootdown patches to go via the -mm tree we could do these
> now.
> 
> It basically just removing a bunch of dead code, or replacing them
> with WARN so we can remove them entirely in a release or two.
> 
> [...]

Applied to powerpc/next.

[1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush
      https://git.kernel.org/powerpc/c/45abf5d94b9bd0eebca5c7272788e2d16c8b5b43
[2/3] powerpc/64s/radix: mm->context.id should always be valid
      https://git.kernel.org/powerpc/c/d01dc25e47af9d30185ca12bb9e221d6af915d9f
[3/3] powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes
      https://git.kernel.org/powerpc/c/dcfecb989afdf9101ee42e2adf04756a2ea4819d

cheers

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

end of thread, other threads:[~2023-02-15 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 11:17 [PATCH 0/3] powerpc/64s/radix: misc tidying Nicholas Piggin
2023-02-03 11:17 ` [PATCH 1/3] powerpc/64s/radix: Remove need_flush_all test from radix__tlb_flush Nicholas Piggin
2023-02-03 11:17 ` [PATCH 2/3] powerpc/64s/radix: mm->context.id should always be valid Nicholas Piggin
2023-02-03 11:17 ` [PATCH 3/3] powerpc/64s/radix: Remove TLB_FLUSH_ALL test from range flushes Nicholas Piggin
2023-02-15 12:40 ` [PATCH 0/3] powerpc/64s/radix: misc tidying 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).