linux-stable/arch/mips/kernel
Valentin Schneider 3c51d82d0b sched/core: Initialize the idle task with preemption disabled
[ Upstream commit f1a0a376ca ]

As pointed out by commit

  de9b8f5dcb ("sched: Fix crash trying to dequeue/enqueue the idle thread")

init_idle() can and will be invoked more than once on the same idle
task. At boot time, it is invoked for the boot CPU thread by
sched_init(). Then smp_init() creates the threads for all the secondary
CPUs and invokes init_idle() on them.

As the hotplug machinery brings the secondaries to life, it will issue
calls to idle_thread_get(), which itself invokes init_idle() yet again.
In this case it's invoked twice more per secondary: at _cpu_up(), and at
bringup_cpu().

Given smp_init() already initializes the idle tasks for all *possible*
CPUs, no further initialization should be required. Now, removing
init_idle() from idle_thread_get() exposes some interesting expectations
with regards to the idle task's preempt_count: the secondary startup always
issues a preempt_disable(), requiring some reset of the preempt count to 0
between hot-unplug and hotplug, which is currently served by
idle_thread_get() -> idle_init().

Given the idle task is supposed to have preemption disabled once and never
see it re-enabled, it seems that what we actually want is to initialize its
preempt_count to PREEMPT_DISABLED and leave it there. Do that, and remove
init_idle() from idle_thread_get().

Secondary startups were patched via coccinelle:

  @begone@
  @@

  -preempt_disable();
  ...
  cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);

Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210512094636.2958515-1-valentin.schneider@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-14 16:55:50 +02:00
..
syscalls mm/madvise: introduce process_madvise() syscall: an external memory hinting API 2020-10-18 09:27:10 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
asm-offsets.c
binfmt_elfn32.c MIPS: Fix malformed NT_FILE and NT_SIGINFO in 32bit coredumps 2021-01-19 18:27:20 +01:00
binfmt_elfo32.c MIPS: Fix malformed NT_FILE and NT_SIGINFO in 32bit coredumps 2021-01-19 18:27:20 +01:00
bmips_5xxx_init.S
bmips_vec.S
branch.c MIPS: kernel: include probes-common.h header in branch.c 2020-09-21 22:14:24 +02:00
cacheinfo.c mips: cacheinfo: report shared CPU map 2019-11-26 10:33:08 -08:00
cevt-bcm1480.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-ds1287.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-gt641xx.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-r4k.c mips: cevt-r4k: Update the r4k-clockevent frequency in sync with CPU 2020-05-22 09:14:32 +02:00
cevt-sb1250.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-txx9.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cmpxchg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cps-vec-ns16550.S mips: Add CPS_NS16550_WIDTH config 2020-05-22 09:12:52 +02:00
cps-vec.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cpu-probe.c MIPS: Loongson64: Use _CACHE_UNCACHED instead of _CACHE_UNCACHED_ACCELERATED 2021-05-19 10:12:55 +02:00
cpu-r3k-probe.c MIPS: cpu-probe: introduce exclusive R3k CPU probe 2020-10-12 12:05:16 +02:00
crash.c
crash_dump.c
csrc-bcm1480.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
csrc-ioasic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
csrc-r4k.c mips: csrc-r4k: Mark R4K timer as unstable if CPU freq changes 2020-05-22 09:14:06 +02:00
csrc-sb1250.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
early_printk.c
early_printk_8250.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
elf.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
entry.S mips: Add MIPS Release 5 support 2020-05-22 09:09:01 +02:00
fpu-probe.c MIPS: cpu-probe: move fpu probing/handling into its own file 2020-10-12 12:04:50 +02:00
fpu-probe.h MIPS: cpu-probe: move fpu probing/handling into its own file 2020-10-12 12:04:50 +02:00
ftrace.c MIPS: ftrace: Remove redundant #ifdef CONFIG_DYNAMIC_FTRACE 2020-08-17 13:00:24 +02:00
genex.S MIPS: handle Loongson-specific GSExc exception 2020-07-31 17:52:47 +02:00
gpio_txx9.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
head.S MIPS: Loongson-3: Enable COP2 usage in kernel 2020-09-21 22:15:03 +02:00
i8253.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
idle.c sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
irq-gt641xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
irq-msc01.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-rm7000.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq.c
irq_txx9.c
jump_label.c MIPS: jump_label: Use compact branches for >= r6 2019-04-09 16:21:30 -07:00
kgdb.c
kprobes.c mips: kprobes: Use generic kretprobe trampoline handler 2020-09-08 11:52:33 +02:00
linux32.c
machine_kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
Makefile MIPS: cpu-probe: introduce exclusive R3k CPU probe 2020-10-12 12:05:16 +02:00
mcount.S
mips-cm.c mips: cm: Add L2 ECC/parity errors reporting 2020-05-07 13:11:38 +02:00
mips-cpc.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
mips-mt-fpaff.c MIPS: Use rcu to lookup a task in mipsmt_sys_sched_setaffinity() 2020-09-03 10:13:43 +02:00
mips-mt.c
mips-r2-to-r6-emul.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
module.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
octeon_switch.S
perf_event.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
perf_event_mipsxx.c MIPS: perf: Fix wrong check condition of Loongson event IDs 2020-09-01 13:52:33 +02:00
pm-cps.c MIPS: barrier: Add __SYNC() infrastructure 2019-10-07 09:42:17 -07:00
pm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
probes-common.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
proc.c mips: Add MIPS Release 5 support 2020-05-22 09:09:01 +02:00
process.c MIPS: process: include exec.h header in process.c 2020-09-30 21:53:00 +02:00
prom.c MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
ptrace.c mips: switch to ->regset_get() 2020-07-27 14:31:08 -04:00
ptrace32.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
r4k-bugs64.c MIPS: r4k-bugs64: Drop CONFIG_CPU_MIPSR6 checks 2019-10-07 09:38:54 -07:00
r4k_fpu.S mips: Add MIPS Release 5 support 2020-05-22 09:09:01 +02:00
r4k_switch.S
r2300_fpu.S
r2300_switch.S
relocate.c MIPS: relocatable: fix possible boot hangup with KASLR enabled 2021-01-19 18:27:20 +01:00
relocate_kernel.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
reset.c
rtlx-cmp.c
rtlx-mt.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
rtlx.c
scall32-o32.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-n32.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-n64.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-o32.S MIPS: asm: Rename some macros to avoid build errors 2020-05-07 13:20:05 +02:00
segment.c
setup.c MIPS: Don't round up kernel sections size for memblock_add() 2020-12-30 11:53:34 +01:00
signal-common.h
signal.c tracehook: clear TIF_NOTIFY_RESUME in tracehook_notify_resume() 2020-10-17 15:04:36 -06:00
signal32.c
signal_n32.c Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2019-07-08 21:48:15 -07:00
signal_o32.c signal: Remove task parameter from force_sig 2019-05-27 09:36:28 -05:00
smp-bmips.c MIPS: BMIPS: Also call bmips_cpu_setup() for secondary cores 2020-08-21 09:29:09 +02:00
smp-cmp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 182 2019-05-30 11:29:20 -07:00
smp-cps.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
smp-mt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 182 2019-05-30 11:29:20 -07:00
smp-up.c
smp.c sched/core: Initialize the idle task with preemption disabled 2021-07-14 16:55:50 +02:00
spinlock_test.c
spram.c mips: Add CONFIG/CONFIG6/Cause reg fields macro 2020-05-22 09:12:22 +02:00
stacktrace.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
sync-r4k.c MIPS: sync-r4k: do slave counter synchronization with disabled HW interrupts 2020-01-22 10:16:18 -08:00
syscall.c MIPS: Convert R10000_LLSC_WAR info a config option 2020-09-07 22:24:27 +02:00
sysrq.c MIPS: constify sysrq_key_op 2020-05-15 14:53:19 +02:00
time.c mips: Add udelay lpj numbers adjustment 2020-05-22 09:13:32 +02:00
topology.c MIPS: CPU#0 is not hotpluggable 2020-07-26 10:18:35 +02:00
traps.c MIPS updates for v5.10: 2020-10-16 12:40:55 -07:00
unaligned.c uaccess: add force_uaccess_{begin,end} helpers 2020-08-12 10:57:59 -07:00
uprobes.c MIPS: uprobes: remove set but not used variable 'epc' 2019-05-29 13:20:30 -07:00
vdso.c mmap locking API: use coccinelle to convert mmap_sem rwsem call sites 2020-06-09 09:39:14 -07:00
vmlinux.lds.S MIPS: properly stop .eh_frame generation 2021-03-04 11:37:41 +01:00
vpe-cmp.c
vpe-mt.c
vpe.c MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()' 2020-02-15 12:44:03 -08:00
watch.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00