linux-stable/arch/mips/kernel
Matt Redfearn 9e8c399a88 MIPS: SMP: Fix deadlock & online race
Commit 6f542ebeae ("MIPS: Fix race on setting and getting
cpu_online_mask") effectively reverted commit 8f46cca1e6 ("MIPS: SMP:
Fix possibility of deadlock when bringing CPUs online") and thus has
reinstated the possibility of deadlock.

The commit was based on testing of kernel v4.4, where the CPU hotplug
core code issued a BUG() if the starting CPU is not marked online when
the boot CPU returns from __cpu_up. The commit fixes this race (in
v4.4), but re-introduces the deadlock situation.

As noted in the commit message, upstream differs in this area. Commit
8df3e07e7f ("cpu/hotplug: Let upcoming cpu bring itself fully up")
adds a completion event in the CPU hotplug core code, making this race
impossible. However, people were unhappy with relying on the core code
to do the right thing.

To address the issues both commits were trying to fix, add a second
completion event in the MIPS smp hotplug path. It removes the
possibility of a race, since the MIPS smp hotplug code now synchronises
both the boot and secondary CPUs before they return to the hotplug core
code. It also addresses the deadlock by ensuring that the secondary CPU
is not marked online before it's counters are synchronised.

This fix should also be backported to fix the race condition introduced
by the backport of commit 8f46cca1e6 ("MIPS: SMP: Fix possibility of
deadlock when bringing CPUs online"), through really that race only
existed before commit 8df3e07e7f ("cpu/hotplug: Let upcoming cpu
bring itself fully up").

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Fixes: 6f542ebeae ("MIPS: Fix race on setting and getting cpu_online_mask")
CC: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
Cc: <stable@vger.kernel.org> # v4.1+: 8f46cca1e6: "MIPS: SMP: Fix possibility of deadlock when bringing CPUs online"
Cc: <stable@vger.kernel.org> # v4.1+: a00eeede50: "MIPS: SMP: Use a completion event to signal CPU up"
Cc: <stable@vger.kernel.org> # v4.1+: 6f542ebeae: "MIPS: Fix race on setting and getting cpu_online_mask"
Cc: <stable@vger.kernel.org> # v4.1+
Patchwork: https://patchwork.linux-mips.org/patch/17376/
Signed-off-by: James Hogan <jhogan@kernel.org>
2017-11-01 00:09:17 +00:00
..
.gitignore
8250-platform.c
asm-offsets.c MIPS: IRQ Stack: Unwind IRQ stack onto task stack 2017-03-22 11:53:57 +01:00
binfmt_elfn32.c fs/binfmt: Convert obsolete cputime type to nsecs 2017-02-01 09:13:51 +01:00
binfmt_elfo32.c fs/binfmt: Convert obsolete cputime type to nsecs 2017-02-01 09:13:51 +01:00
bmips_5xxx_init.S MIPS: BMIPS: Make whitespacely correct. 2016-05-09 12:00:01 +02:00
bmips_vec.S MIPS: BMIPS: Add Whirlwind (BMIPS5200) initialization code 2016-05-09 12:00:01 +02:00
branch.c MIPS: Use pr_debug' for messages from __compute_return_epc_for_insn' 2017-06-29 02:42:27 +02:00
cacheinfo.c MIPS: Fix cacheinfo overflow 2017-02-13 18:57:34 +00:00
cevt-bcm1480.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-ds1287.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-gt641xx.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-r4k.c MIPS: cevt-r4k: Fix out-of-bounds array access 2017-04-10 13:31:12 +02:00
cevt-sb1250.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-txx9.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cmpxchg.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
cps-vec-ns16550.S Update MIPS email addresses 2017-10-31 22:42:39 +00:00
cps-vec.S Update MIPS email addresses 2017-10-31 22:42:39 +00:00
cpu-bugs64.c MIPS: Fix printk continuations in cpu-bugs64.c 2017-01-24 18:30:34 +01:00
cpu-probe.c MIPS: Add CPU cluster number accessors 2017-08-30 00:57:27 +02:00
crash.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
crash_dump.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
csrc-bcm1480.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-ioasic.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-r4k.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-sb1250.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
early_printk.c
early_printk_8250.c
elf.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
entry.S MIPS: Fix IRQ tracing & lockdep when rescheduling 2017-06-30 04:40:18 +02:00
ftrace.c MIPS: ftrace: fix init functions tracing 2017-06-08 14:51:59 +02:00
genex.S MIPS: Add DWARF unwinding to assembly 2017-09-06 11:01:52 +02:00
gpio_txx9.c MIPS: txx9: switch to gpiochip_add_data() 2016-02-19 09:51:44 +01:00
head.S MIPS: head: Reorder instructions missing a delay slot 2017-06-27 23:35:21 +02:00
i8253.c
idle.c MIPS: Include linux/cpu.h for arch_cpu_idle() 2017-08-29 15:21:54 +02:00
irq-gt641xx.c
irq-msc01.c
irq-rm7000.c
irq.c MIPS: Introduce irq_stack 2017-01-03 16:34:34 +01:00
irq_txx9.c
jump_label.c jump_label: Reorder hotplug lock and jump_label_lock 2017-05-26 10:10:45 +02:00
kgdb.c MIPS: KGDB: Use kernel context for sleeping threads 2017-04-12 22:29:22 +02:00
kprobes.c MIPS: tracing: disable uprobe/kprobe on compact branch instructions 2016-10-06 17:37:40 +02:00
linux32.c MIPS: Return directly in 32_mmap2() 2017-01-25 02:51:11 +01:00
machine_kexec.c MIPS: kexec: add debug info about the new kexec'ed image 2017-01-03 16:34:46 +01:00
Makefile MIPS: Move r4k FP code from r4k_switch.S to r4k_fpu.S 2017-08-29 15:21:51 +02:00
mcount.S MIPS: Export _mcount alongside its definition 2017-01-03 16:34:49 +01:00
mips-cm.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
mips-cpc.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
mips-mt-fpaff.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task.h> 2017-03-02 08:42:35 +01:00
mips-mt.c
mips-r2-to-r6-emul.c MIPS: Declare various variables & functions static 2017-08-29 15:21:55 +02:00
mips_machine.c
module.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
octeon_switch.S MIPS: Move r4k FP code from r4k_switch.S to r4k_fpu.S 2017-08-29 15:21:51 +02:00
perf_event.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
perf_event_mipsxx.c MIPS: Fix perf event init 2017-09-20 10:47:12 +02:00
pm-cps.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
pm.c MIPS: Fix watchpoint restoration 2016-05-09 12:00:02 +02:00
probes-common.h MIPS: tracing: disable uprobe/kprobe on compact branch instructions 2016-10-06 17:37:40 +02:00
proc.c MIPS: Abstract CPU core & VP(E) ID access through accessor functions 2017-08-30 00:57:26 +02:00
process.c MIPS: Refactor handling of stack pointer in get_frame_info 2017-09-06 13:21:44 +02:00
prom.c MIPS: Use early_init_fdt_reserve_self to protect DTB location 2017-01-03 16:34:45 +01:00
ptrace.c MIPS: seccomp: Fix indirect syscall args 2017-08-29 15:42:44 +02:00
ptrace32.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
r4k_fpu.S MIPS: Move r4k FP code from r4k_switch.S to r4k_fpu.S 2017-08-29 15:21:51 +02:00
r4k_switch.S MIPS: Move r4k FP code from r4k_switch.S to r4k_fpu.S 2017-08-29 15:21:51 +02:00
r2300_fpu.S MIPS: Move r2300 FP code from r2300_switch.S to r2300_fpu.S 2017-08-29 15:21:51 +02:00
r2300_switch.S MIPS: Remove unused ST_OFF from r2300_switch.S 2017-08-29 15:21:51 +02:00
relocate.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
relocate_kernel.S MIPS: Replace add and sub instructions in relocate_kernel.S with addiu 2015-08-03 15:26:30 +02:00
reset.c MIPS: Provide fallback reboot/poweroff/halt implementations 2015-04-01 17:21:58 +02:00
rtlx-cmp.c
rtlx-mt.c
rtlx.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
scall32-o32.S MIPS: Remove pt_regs adjustments in indirect syscall handler 2017-08-29 15:48:34 +02:00
scall64-64.S MIPS: Save static registers before sysmips 2017-06-28 12:22:40 +02:00
scall64-n32.S MIPS: Save static registers before sysmips 2017-06-28 12:22:40 +02:00
scall64-o32.S MIPS: Remove pt_regs adjustments in indirect syscall handler 2017-08-29 15:48:34 +02:00
segment.c MIPS: Print segment physical address when EU=1 2016-07-28 11:44:30 +02:00
setup.c MIPS: cmdline: Add support for 'memmap' parameter 2017-06-29 02:42:23 +02:00
signal-common.h MIPS: Save MSA extended context around signals 2015-09-03 12:07:59 +02:00
signal.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2016-08-06 09:13:11 -04:00
signal32.c signal: Remove kernel interal si_code magic 2017-07-24 14:30:28 -05:00
signal_n32.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
signal_o32.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
smp-bmips.c MIPS: SMP: Allow boot_secondary SMP op to return errors 2017-08-30 00:57:27 +02:00
smp-cmp.c MIPS: Remove unnecessary inclusions of linux/irqchip/mips-gic.h 2017-09-04 13:53:14 +02:00
smp-cps.c Update MIPS email addresses 2017-10-31 22:42:39 +00:00
smp-mt.c MIPS: Use mips_gic_present() in place of gic_present 2017-09-04 13:53:14 +02:00
smp-up.c MIPS: SMP: Allow boot_secondary SMP op to return errors 2017-08-30 00:57:27 +02:00
smp.c MIPS: SMP: Fix deadlock & online race 2017-11-01 00:09:17 +00:00
spinlock_test.c MIPS: Declare mips_debugfs_dir in a header 2015-10-26 09:49:42 +01:00
spram.c MIPS: Add P6600 cases to CPU switch statements 2016-05-13 14:01:52 +02:00
stacktrace.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
sync-r4k.c MIPS: sync-r4k: Fix KERN_CONT fallout 2017-02-13 18:58:39 +00:00
syscall.c MIPS: Branch straight to ll in mips_atomic_set() 2017-06-28 12:22:40 +02:00
sysrq.c MIPS: Refactor dumping of TLB registers for r3k/r4k 2015-09-03 12:07:45 +02:00
time.c MIPS: Remove plat_timer_setup() 2017-08-29 15:21:55 +02:00
topology.c
traps.c MIPS: CPS: Have asm/mips-cps.h include CM & CPC headers 2017-08-30 00:57:27 +02:00
unaligned.c MIPS: Declare various variables & functions static 2017-08-29 15:21:55 +02:00
uprobes.c MIPS: uprobes: Remove __weak attribute from arch_uprobe_copy_ixol. 2017-01-03 16:34:48 +01:00
vdso.c MIPS: VDSO: Drop gic_get_usm_range() usage 2017-09-04 13:53:14 +02:00
vmlinux.lds.S debug: Fix __bug_table[] in arch linker scripts 2017-04-03 10:22:40 +02:00
vpe-cmp.c
vpe-mt.c
vpe.c module: use a structure to encapsulate layout. 2015-12-04 22:46:25 +01:00
watch.c MIPS: Add and use watch register field definitions 2016-05-13 14:02:13 +02:00