mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2 v2] x86,tlb: context switch optimizations
@ 2024-11-14 15:26 Rik van Riel
  2024-11-14 15:26 ` [PATCH 1/2] x86,tlb: update mm_cpumask lazily Rik van Riel
  2024-11-14 15:26 ` [PATCH 2/2] x86,tlb: add tracepoint for TLB flush IPI to stale CPU Rik van Riel
  0 siblings, 2 replies; 7+ messages in thread
From: Rik van Riel @ 2024-11-14 15:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: dave.hansen, luto, peterz, tglx, mingo, bp, x86, kernel-team, hpa

While profiling switch_mm_irqs_off with several workloads,
it appears there are two hot spots that probably don't need
to be there.

The patch placing the mm_cpumask test inside the prev == next
branch behind CONFIG_DEBUG_VM got merged into x86/mm already,
so here are the other two.

The approach used in v2 to ensure the call to flush_mm_tlb_range()
from __text_poke() remains a noop is to clear the CPU from the
mm_cpumask of poke_mm. Fix suggested by Peter Zijlstra.

That way the only thing flush_mm_tlb_range() really ends up
doing is increment the tlb_gen, resulting in future users of
poke_mm flushing the TLB.


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH 2/3] x86,tlb: add tracepoint for TLB flush IPI to stale CPU
@ 2024-11-09  0:27 Rik van Riel
  2024-11-13  2:59 ` [tip: x86/mm] x86/mm/tlb: Add " tip-bot2 for Rik van Riel
  0 siblings, 1 reply; 7+ messages in thread
From: Rik van Riel @ 2024-11-09  0:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: dave.hansen, luto, peterz, tglx, mingo, bp, x86, kernel-team,
	hpa, Rik van Riel, Dave Hansen

Add a tracepoint when we send a TLB flush IPI to a CPU that used
to be in the mm_cpumask, but isn't any more.

This can be used to evaluate whether there any workloads where
we end up in this path problematically often. Hopefully they
don't exist.

Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Rik van Riel <riel@surriel.com>
---
 arch/x86/mm/tlb.c        | 1 +
 include/linux/mm_types.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index f19f6378cabf..9d0d34576928 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -760,6 +760,7 @@ static void flush_tlb_func(void *info)
 		/* Can only happen on remote CPUs */
 		if (f->mm && f->mm != loaded_mm) {
 			cpumask_clear_cpu(raw_smp_processor_id(), mm_cpumask(f->mm));
+			trace_tlb_flush(TLB_REMOTE_WRONG_CPU, 0);
 			return;
 		}
 	}
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 6e3bdf8e38bc..6b6f05404304 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1335,6 +1335,7 @@ enum tlb_flush_reason {
 	TLB_LOCAL_SHOOTDOWN,
 	TLB_LOCAL_MM_SHOOTDOWN,
 	TLB_REMOTE_SEND_IPI,
+	TLB_REMOTE_WRONG_CPU,
 	NR_TLB_FLUSH_REASONS,
 };
 
-- 
2.45.2


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

end of thread, other threads:[~2024-11-19 12:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14 15:26 [PATCH 0/2 v2] x86,tlb: context switch optimizations Rik van Riel
2024-11-14 15:26 ` [PATCH 1/2] x86,tlb: update mm_cpumask lazily Rik van Riel
2024-11-19 11:27   ` [tip: x86/mm] x86/mm/tlb: Update " tip-bot2 for Rik van Riel
2024-11-19 12:54     ` Peter Zijlstra
2024-11-14 15:26 ` [PATCH 2/2] x86,tlb: add tracepoint for TLB flush IPI to stale CPU Rik van Riel
2024-11-19 11:27   ` [tip: x86/mm] x86/mm/tlb: Add " tip-bot2 for Rik van Riel
  -- strict thread matches above, loose matches on Subject: below --
2024-11-09  0:27 [PATCH 2/3] x86,tlb: add " Rik van Riel
2024-11-13  2:59 ` [tip: x86/mm] x86/mm/tlb: Add " tip-bot2 for Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®