linux-sg2042/arch/arm
Valentin Schneider f1a0a376ca sched/core: Initialize the idle task with preemption disabled
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
2021-05-12 13:01:45 +02:00
..
boot Kbuild updates for v5.13 (2nd) 2021-05-08 10:00:11 -07:00
common ARM: 9049/1: locomo: make locomo bus's remove callback return void 2021-02-01 19:44:30 +00:00
configs Merge branch 'akpm' (patches from Andrew) 2021-05-07 00:34:51 -07:00
crypto crypto: arm/curve25519 - Move '.fpu' after '.arch' 2021-04-16 21:16:34 +10:00
include Merge branch 'akpm' (patches from Andrew) 2021-05-07 00:34:51 -07:00
kernel sched/core: Initialize the idle task with preemption disabled 2021-05-12 13:01:45 +02:00
lib
mach-actions
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed
mach-at91 ARM: at91: pm: Move prototypes to mutually included header 2021-03-26 18:20:49 +01:00
mach-axxia
mach-bcm
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci ARM: davinci: Constify the software nodes 2021-04-08 23:45:55 +02:00
mach-digicolor
mach-dove
mach-ep93xx
mach-exynos ARM: exynos: correct kernel doc in platsmp 2021-04-06 22:30:02 +02:00
mach-footbridge ARM updates for 5.13-rc1: 2021-05-06 09:28:07 -07:00
mach-gemini
mach-highbank
mach-hisi ARM: hisi: use the correct HiSilicon copyright 2021-04-02 15:36:27 +08:00
mach-imx ARM: SoC changes for v5.13 2021-04-26 11:48:26 -07:00
mach-integrator
mach-iop32x ARM: iop32x: disable N2100 PCI parity reporting 2021-03-31 12:29:40 -05:00
mach-ixp4xx
mach-keystone ARM: keystone: fix integer overflow warning 2021-04-01 16:32:37 +02:00
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-milbeaut
mach-mmp
mach-moxart
mach-mstar ARM: mstar: Select MSTAR_MSC313_MPLL 2021-04-01 12:40:55 +02:00
mach-mv78xx0
mach-mvebu of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
mach-mxs
mach-nomadik
mach-npcm ARM: npcm: Introduce Nuvoton WPCM450 SoC 2021-04-09 14:11:22 +09:30
mach-nspire
mach-omap1 Merge branch 'i2c/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-04-30 13:01:02 -07:00
mach-omap2 ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
mach-orion5x
mach-oxnas
mach-pxa Merge branch 'i2c/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-04-30 13:01:02 -07:00
mach-qcom
mach-rda
mach-realtek
mach-realview
mach-rockchip
mach-rpc
mach-s3c Merge branch 'i2c/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-04-30 13:01:02 -07:00
mach-s5pv210
mach-sa1100 ARM: 9049/1: locomo: make locomo bus's remove callback return void 2021-02-01 19:44:30 +00:00
mach-shmobile
mach-socfpga ARM: socfpga: drop ARCH_SOCFPGA 2021-03-23 11:03:36 -05:00
mach-spear ARM/spi: spear: Drop PL022 num_chipselect 2021-04-08 15:21:58 +01:00
mach-sti
mach-stm32 ARM: stm32: Add a new SoC - STM32H750 2021-04-01 09:54:45 +02:00
mach-sunxi
mach-tegra
mach-uniphier
mach-ux500 ARM: ux500: make ux500_cpu_die static 2021-04-01 22:30:49 +02:00
mach-versatile
mach-vexpress
mach-vt8500
mach-zynq
mm ARM updates for 5.13-rc1: 2021-05-06 09:28:07 -07:00
net
nwfpe
plat-omap ARM: OMAP2+: Use DEFINE_SPINLOCK() for spinlock 2021-03-31 08:58:42 +03:00
plat-orion
plat-pxa
plat-versatile
probes ARM updates for 5.13-rc1: 2021-05-06 09:28:07 -07:00
tools ARM updates for 5.13-rc1: 2021-05-06 09:28:07 -07:00
vdso ARM: 9051/1: vdso: remove unneded extra-y addition 2021-02-01 19:48:06 +00:00
vfp
xen Merge branch 'stable/for-linus-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb 2021-05-04 10:58:49 -07:00
Kbuild
Kconfig mm: drop redundant HAVE_ARCH_TRANSPARENT_HUGEPAGE 2021-05-05 11:27:25 -07:00
Kconfig-nommu
Kconfig.assembler
Kconfig.debug ARM: socfpga: introduce common ARCH_INTEL_SOCFPGA 2021-03-23 11:03:35 -05:00
Makefile ARM: socfpga: introduce common ARCH_INTEL_SOCFPGA 2021-03-23 11:03:35 -05:00