Revert "x86/mm: Stop calling leave_mm() in idle code"
This reverts commit 43858b4f25cf0adc5c2ca9cf5ce5fdf2532941e5.
The reason I removed the leave_mm() calls in question is because the
heuristic wasn't needed after that patch. With the original version
of my PCID series, we never flushed a "lazy cpu" (i.e. a CPU running
kernel thread) due a flush on the loaded mm.
Unfortunately, that caused architectural issues, so now I've
reinstated these flushes on non-PCID systems in:
commit b956575bed91 ("x86/mm: Flush more aggressively in lazy TLB mode").
That, in turn, gives us a power management and occasionally
performance regression as compared to old kernels: a process that
goes into a deep idle state on a given CPU and gets its mm flushed
due to activity on a different CPU will wake the idle CPU.
Reinstate the old ugly heuristic: if a CPU goes into ACPI C3 or an
intel_idle state that is likely to cause a TLB flush gets its mm
switched to init_mm before going idle.
FWIW, this heuristic is lousy. Whether we should change CR3 before
idle isn't a good hint except insofar as the performance hit is a bit
lower if the TLB is getting flushed by the idle code anyway. What we
really want to know is whether we anticipate being idle long enough
that the mm is likely to be flushed before we wake up. This is more a
matter of the expected latency than the idle state that gets chosen.
This heuristic also completely fails on systems that don't know
whether the TLB will be flushed (e.g. AMD systems?). OTOH it may be a
bit obsolete anyway -- PCID systems don't presently benefit from this
heuristic at all.
We also shouldn't do this callback from innermost bit of the idle code
due to the RCU nastiness it causes. All the information need is
available before rcu_idle_enter() needs to happen.
Signed-off-by: Andy Lutomirski <email@example.com>
Cc: Borislav Petkov <firstname.lastname@example.org>
Cc: Borislav Petkov <email@example.com>
Cc: Brian Gerst <firstname.lastname@example.org>
Cc: Denys Vlasenko <email@example.com>
Cc: H. Peter Anvin <firstname.lastname@example.org>
Cc: Josh Poimboeuf <email@example.com>
Cc: Linus Torvalds <firstname.lastname@example.org>
Cc: Peter Zijlstra <email@example.com>
Cc: Thomas Gleixner <firstname.lastname@example.org>
Fixes: 43858b4f25cf "x86/mm: Stop calling leave_mm() in idle code"
Signed-off-by: Ingo Molnar <email@example.com>
5 files changed