public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCh 0/3] x86,tlb: context switch optimizations
@ 2024-11-09  0:27 Rik van Riel
  2024-11-09  0:27 ` [PATCH 1/3] x86,tlb: update mm_cpumask lazily Rik van Riel
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ 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

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 first is the atomic clearing and setting of the current
CPU in prev's and next's mm_cpumask. This can create a large
amount of cache line contention. On a web server, these two
together take about 17% of the CPU time spent in switch_mm_irqs_off.

We should be able to avoid much of the cache line thrashing
by only clearing bits in mm_cpumask lazily from the first
TLB flush to a process, after which the other TLB flushes can
be more narrowly targeted.

A second cause of overhead seems to be the cpumask_test_cpu
inside the WARN_ON_ONCE in the prev == next branch of
switch_mm_irqs_off.

This warning never ever seems to fire, even on a very large
fleet, so it may be best to hide that behind CONFIG_DEBUG_VM.
With the web server workload, this is also about 17% of
switch_mm_irqs_off.


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

end of thread, other threads:[~2024-11-14 14:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09  0:27 [PATCh 0/3] x86,tlb: context switch optimizations Rik van Riel
2024-11-09  0:27 ` [PATCH 1/3] x86,tlb: update mm_cpumask lazily Rik van Riel
2024-11-13  2:59   ` [tip: x86/mm] x86/mm/tlb: Update " tip-bot2 for Rik van Riel
2024-11-09  0:27 ` [PATCH 2/3] x86,tlb: add tracepoint for TLB flush IPI to stale CPU Rik van Riel
2024-11-13  2:59   ` [tip: x86/mm] x86/mm/tlb: Add " tip-bot2 for Rik van Riel
2024-11-09  0:27 ` [PATCH 3/3] x86,tlb: put cpumask_test_cpu in prev == next under CONFIG_DEBUG_VM Rik van Riel
2024-11-13  2:59   ` [tip: x86/mm] x86/mm/tlb: Put cpumask_test_cpu() check in switch_mm_irqs_off() " tip-bot2 for Rik van Riel
2024-11-13  9:55 ` [PATCh 0/3] x86,tlb: context switch optimizations Borislav Petkov
2024-11-13 10:00   ` Ingo Molnar
2024-11-13 14:38   ` Rik van Riel
2024-11-14 11:33     ` Peter Zijlstra
2024-11-13 14:55   ` Rik van Riel
2024-11-14  9:52     ` Ingo Molnar
2024-11-14 11:36       ` Peter Zijlstra
2024-11-14 14:27       ` Rik van Riel
2024-11-14 14:40         ` Peter Zijlstra
2024-11-14 11:36     ` Peter Zijlstra
2024-11-14 11:43       ` Peter Zijlstra

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