android_kernel_samsung_msm8976/arch/x86
Wanpeng Li 90d52e914e sched: Fix unreleased llc_shared_mask bit during CPU hotplug
commit 03bd4e1f7265548832a76e7919a81f3137c44fd1 upstream.

The following bug can be triggered by hot adding and removing a large number of
xen domain0's vcpus repeatedly:

	BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 IP: [..] find_busiest_group
	PGD 5a9d5067 PUD 13067 PMD 0
	Oops: 0000 [#3] SMP
	[...]
	Call Trace:
	load_balance
	? _raw_spin_unlock_irqrestore
	idle_balance
	__schedule
	schedule
	schedule_timeout
	? lock_timer_base
	schedule_timeout_uninterruptible
	msleep
	lock_device_hotplug_sysfs
	online_store
	dev_attr_store
	sysfs_write_file
	vfs_write
	SyS_write
	system_call_fastpath

Last level cache shared mask is built during CPU up and the
build_sched_domain() routine takes advantage of it to setup
the sched domain CPU topology.

However, llc_shared_mask is not released during CPU disable,
which leads to an invalid sched domainCPU topology.

This patch fix it by releasing the llc_shared_mask correctly
during CPU disable.

Yasuaki also reported that this can happen on real hardware:

  https://lkml.org/lkml/2014/7/22/1018

His case is here:

	==
	Here is an example on my system.
	My system has 4 sockets and each socket has 15 cores and HT is
	enabled. In this case, each core of sockes is numbered as
	follows:

		 | CPU#
	Socket#0 | 0-14 , 60-74
	Socket#1 | 15-29, 75-89
	Socket#2 | 30-44, 90-104
	Socket#3 | 45-59, 105-119

	Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.

	It means that last level cache of Socket#2 is shared with
	CPU#30-44 and 90-104.

	When hot-removing socket#2 and #3, each core of sockets is
	numbered as follows:

		 | CPU#
	Socket#0 | 0-14 , 60-74
	Socket#1 | 15-29, 75-89

	But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30
	remains having 0x3fff80000001fffc0000000.

	After that, when hot-adding socket#2 and #3, each core of
	sockets is numbered as follows:

		 | CPU#
	Socket#0 | 0-14 , 60-74
	Socket#1 | 15-29, 75-89
	Socket#2 | 30-59
	Socket#3 | 90-119

	Then llc_shared_mask of CPU#30 becomes
	0x3fff8000fffffffc0000000. It means that last level cache of
	Socket#2 is shared with CPU#30-59 and 90-104. So the mask has
	the wrong value.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
Tested-by: Linn Crosetto <linn@hp.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1411547885-48165-1-git-send-email-wanpeng.li@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-05 14:54:14 -07:00
..
boot x86/efi: Include a .bss section within the PE/COFF headers 2014-07-31 12:53:52 -07:00
configs
crypto crypto: sha512_ssse3 - fix byte count to bit count conversion 2014-07-17 15:58:01 -07:00
ia32 Introduce [compat_]save_altstack_ex() to unbreak x86 SMAP 2013-09-26 17:18:13 -07:00
include x86 early_ioremap: Increase FIX_BTMAPS_SLOTS to 8 2014-10-05 14:54:11 -07:00
kernel sched: Fix unreleased llc_shared_mask bit during CPU hotplug 2014-10-05 14:54:14 -07:00
kvm KVM: x86: handle idiv overflow at kvm_write_tsc 2014-10-05 14:54:11 -07:00
lguest Merge branch 'x86-paravirt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-04-30 08:41:21 -07:00
lib x86, smap: Handle csum_partial_copy_*_user() 2013-09-26 17:18:13 -07:00
math-emu
mm x86-64, espfix: Don't leak bits 31:16 of %esp returning to 16-bit stack 2014-08-07 14:30:26 -07:00
net x86: bpf_jit: support negative offsets 2014-03-31 09:58:13 -07:00
oprofile
pci x86: don't exclude low BIOS area when allocating address space for non-PCI cards 2014-09-05 16:28:36 -07:00
platform x86/efi: Fix off-by-one bug in EFI Boot Services reservation 2014-02-06 11:08:12 -08:00
power x86, gdt, hibernate: Store/load GDT for hibernate path. 2013-05-02 11:27:35 -07:00
realmode x86, build: Pass in additional -mno-mmx, -mno-sse options 2013-12-20 07:45:10 -08:00
syscalls x86, x32: Use compat shims for io_{setup,submit} 2014-06-30 20:09:45 -07:00
tools x86, relocs: Move __vvar_page from S_ABS to S_REL 2013-06-12 15:14:57 -07:00
um make SYSCALL_DEFINE<n>-generated wrappers do asmlinkage_protect 2013-03-03 22:58:33 -05:00
vdso Revert "x86-64, modify_ldt: Make support for 16-bit segments a runtime option" 2014-08-07 14:30:26 -07:00
video
xen xen: Fix possible user space selector corruption 2014-02-22 12:41:25 -08:00
.gitignore
Kbuild
Kconfig x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub 2014-09-05 16:28:36 -07:00
Kconfig.cpu
Kconfig.debug Kconfig: consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 2013-04-30 17:04:09 -07:00
Makefile x86, build: Pass in additional -mno-mmx, -mno-sse options 2013-12-20 07:45:10 -08:00
Makefile.um
Makefile_32.cpu