|author||Andy Lutomirski <email@example.com>||2017-11-04 04:16:12 -0700|
|committer||Ingo Molnar <firstname.lastname@example.org>||2017-11-04 15:01:50 +0100|
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" Link: http://email@example.com Signed-off-by: Ingo Molnar <firstname.lastname@example.org>
Diffstat (limited to 'drivers/idle')
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 5dc7ea4b6bc4..f0b06b14e782 100644
@@ -913,15 +913,16 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev,
struct cpuidle_state *state = &drv->states[index];
unsigned long eax = flg2MWAIT(state->flags);
unsigned int cstate;
+ int cpu = smp_processor_id();
cstate = (((eax) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) + 1;
- * NB: if CPUIDLE_FLAG_TLB_FLUSHED is set, this idle transition
- * will probably flush the TLB. It's not guaranteed to flush
- * the TLB, though, so it's not clear that we can do anything
- * useful with this knowledge.
+ * leave_mm() to avoid costly and often unnecessary wakeups
+ * for flushing the user TLB's associated with the active mm.
+ if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
if (!(lapic_timer_reliable_states & (1 << (cstate))))