linux-stable/arch/x86
Andy Lutomirski 675357362a Revert "x86/mm: Stop calling leave_mm() in idle code"
This reverts commit 43858b4f25.

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 b956575bed ("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 <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 43858b4f25 "x86/mm: Stop calling leave_mm() in idle code"
Link: http://lkml.kernel.org/r/c513bbd4e653747213e05bc7062de000bf0202a5.1509793738.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-11-04 15:01:50 +01:00
..
boot Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-09-07 09:42:35 -07:00
configs Merge branch 'x86/urgent' into x86/asm, to pick up fixes 2017-08-10 13:14:15 +02:00
crypto crypto: x86/chacha20 - satisfy stack validation 2.0 2017-10-12 22:51:16 +08:00
entry x86/entry: Fix idtentry unwind hint 2017-10-23 13:30:35 +02:00
events perf/x86/intel/bts: Fix exclusive event reference leak 2017-10-24 13:19:27 +02:00
hyperv x86/hyperv: Fix hypercalls with extended CPU ranges for TLB flushing 2017-10-10 12:54:56 +02:00
ia32 x86/fpu: Rename fpu::fpstate_active to fpu::initialized 2017-09-26 09:43:36 +02:00
include Revert "x86/mm: Stop calling leave_mm() in idle code" 2017-11-04 15:01:50 +01:00
kernel x86/unwind: Show function name+offset in ORC error messages 2017-10-23 13:30:36 +02:00
kvm KVM: nVMX: fix guest CR4 loading when emulating L2 to L1 exit 2017-10-12 13:54:56 +02:00
lib x86/boot: Add early cmdline parsing for options with arguments 2017-07-18 11:38:06 +02:00
math-emu x86/fpu: Rename fpu__activate_curr() to fpu__initialize() 2017-09-26 09:43:44 +02:00
mm Revert "x86/mm: Stop calling leave_mm() in idle code" 2017-11-04 15:01:50 +01:00
net bpf: fix bpf_tail_call() x64 JIT 2017-10-03 16:04:44 -07:00
oprofile
pci dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
platform Merge branch 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-09-09 14:18:40 -07:00
power dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
purgatory
ras x86/mce: Merge mce_amd_inj into mce-inject 2017-06-14 07:32:07 +02:00
realmode x86/boot/realmode: Check for memory encryption on the APs 2017-07-18 11:38:04 +02:00
tools
um um: remove a stray tab 2017-09-13 22:36:27 +02:00
video
xen xen: fixes for 4.14 rc5 2017-10-13 11:35:03 -07:00
.gitignore
Kbuild Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-09-07 09:25:15 -07:00
Kconfig libnvdimm for 4.14 2017-09-11 13:10:57 -07:00
Kconfig.cpu
Kconfig.debug Merge branch 'x86/asm' into locking/core 2017-08-18 10:29:54 +02:00
Makefile x86/build: Use cc-option to validate stack alignment parameter 2017-08-21 09:53:15 +02:00
Makefile.um
Makefile_32.cpu kbuild: remove cc-option-align 2017-06-25 12:43:00 +09:00