linux-stable/arch/mips/kernel
Alexander Lobakin be538b764a MIPS: smp: fill in sibling and core maps earlier
[ Upstream commit f2703def33 ]

After enabling CONFIG_SCHED_CORE (landed during 5.14 cycle),
2-core 2-thread-per-core interAptiv (CPS-driven) started emitting
the following:

[    0.025698] CPU1 revision is: 0001a120 (MIPS interAptiv (multi))
[    0.048183] ------------[ cut here ]------------
[    0.048187] WARNING: CPU: 1 PID: 0 at kernel/sched/core.c:6025 sched_core_cpu_starting+0x198/0x240
[    0.048220] Modules linked in:
[    0.048233] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.17.0-rc3+ #35 b7b319f24073fd9a3c2aa7ad15fb7993eec0b26f
[    0.048247] Stack : 817f0000 00000004 327804c8 810eb050 00000000 00000004 00000000 c314fdd1
[    0.048278]         830cbd64 819c0000 81800000 817f0000 83070bf4 00000001 830cbd08 00000000
[    0.048307]         00000000 00000000 815fcbc4 00000000 00000000 00000000 00000000 00000000
[    0.048334]         00000000 00000000 00000000 00000000 817f0000 00000000 00000000 817f6f34
[    0.048361]         817f0000 818a3c00 817f0000 00000004 00000000 00000000 4dc33260 0018c933
[    0.048389]         ...
[    0.048396] Call Trace:
[    0.048399] [<8105a7bc>] show_stack+0x3c/0x140
[    0.048424] [<8131c2a0>] dump_stack_lvl+0x60/0x80
[    0.048440] [<8108b5c0>] __warn+0xc0/0xf4
[    0.048454] [<8108b658>] warn_slowpath_fmt+0x64/0x10c
[    0.048467] [<810bd418>] sched_core_cpu_starting+0x198/0x240
[    0.048483] [<810c6514>] sched_cpu_starting+0x14/0x80
[    0.048497] [<8108c0f8>] cpuhp_invoke_callback_range+0x78/0x140
[    0.048510] [<8108d914>] notify_cpu_starting+0x94/0x140
[    0.048523] [<8106593c>] start_secondary+0xbc/0x280
[    0.048539]
[    0.048543] ---[ end trace 0000000000000000 ]---
[    0.048636] Synchronize counters for CPU 1: done.

...for each but CPU 0/boot.
Basic debug printks right before the mentioned line say:

[    0.048170] CPU: 1, smt_mask:

So smt_mask, which is sibling mask obviously, is empty when entering
the function.
This is critical, as sched_core_cpu_starting() calculates
core-scheduling parameters only once per CPU start, and it's crucial
to have all the parameters filled in at that moment (at least it
uses cpu_smt_mask() which in fact is `&cpu_sibling_map[cpu]` on
MIPS).

A bit of debugging led me to that set_cpu_sibling_map() performing
the actual map calculation, was being invocated after
notify_cpu_start(), and exactly the latter function starts CPU HP
callback round (sched_core_cpu_starting() is basically a CPU HP
callback).
While the flow is same on ARM64 (maps after the notifier, although
before calling set_cpu_online()), x86 started calculating sibling
maps earlier than starting the CPU HP callbacks in Linux 4.14 (see
[0] for the reference). Neither me nor my brief tests couldn't find
any potential caveats in calculating the maps right after performing
delay calibration, but the WARN splat is now gone.
The very same debug prints now yield exactly what I expected from
them:

[    0.048433] CPU: 1, smt_mask: 0-1

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?id=76ce7cfe35ef

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-19 13:47:48 +01:00
..
syscalls compat: remove some compat entry points 2021-09-08 15:32:35 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Makefile MIPS: Makefile: Replace -pg with CC_FLAGS_FTRACE 2021-04-21 13:44:35 +02:00
access-helper.h MIPS: Fix new sparse warnings 2021-04-07 16:11:05 +02:00
asm-offsets.c sched,arch: Remove unused TASK_STATE offsets 2021-06-18 11:43:09 +02: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 drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() 2021-09-01 10:29:10 +02: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: Remove KVM_GUEST support 2021-03-10 15:18:40 +01:00
cevt-sb1250.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-txx9.c mips: kernel: convert comma to semicolon 2020-12-28 22:32:28 +01:00
cmpxchg.c locking/atomic: mips: move to ARCH_ATOMIC 2021-05-26 13:20:51 +02:00
cps-vec-ns16550.S mips: Add CPS_NS16550_WIDTH config 2020-05-22 09:12:52 +02:00
cps-vec.S MIPS: CPS: don't create redundant .text.cps-vec section 2021-01-15 15:27:54 +01:00
cpu-probe.c MIPS: loongson64: fix FTLB configuration 2021-12-01 09:04:52 +01:00
cpu-r3k-probe.c MIPS: kernel: Reserve exception base early to prevent corruption 2021-03-09 11:22:59 +01:00
crash.c
crash_dump.c MIPS: crash_dump.c: Simplify copy_oldmem_page() 2021-02-09 13:30:12 +01:00
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: kernel: Remove not needed set_fs calls 2021-04-06 14:36:56 +02:00
genex.S MIPS: Make check condition for SDBBP consistent with EJTAG spec 2021-02-11 11:04:31 +01:00
gpio_txx9.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
head.S MIPS: of: Introduce helper function to get DTB 2021-02-04 13:34:51 +01:00
i8253.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
idle.c Revert "MIPS: Remove unused R4300 CPU support" 2021-01-22 11:39:45 +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.c irqchip/mips: Fix RCU violation when using irqdomain lookup on interrupt entry 2021-07-09 10:18:58 +01:00
irq_txx9.c
jump_label.c MIPS: jump_label: Use compact branches for >= r6 2019-04-09 16:21:30 -07:00
kgdb.c MIPS: kernel: Drop kgdb_call_nmi_hook 2021-02-15 12:23:54 +01:00
kprobes.c kprobes: Remove kprobe::fault_handler 2021-06-01 16:00:08 +02:00
linux32.c
machine_kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
mcount.S
mips-cm.c mips: cm: Convert to bitfield API to fix out-of-bounds access 2021-11-18 19:16:58 +01:00
mips-cpc.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
mips-mt-fpaff.c MIPS: Replace deprecated CPU-hotplug functions. 2021-08-05 10:57:01 +02:00
mips-mt.c
mips-r2-to-r6-emul.c MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
module.c MIPS: module: optimize module relocations processing 2021-01-18 15:55:16 +01: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: Add support for OCTEON III perf events. 2021-01-04 11:32:57 +01:00
perf_regs.c MIPS: kernel: Support extracting off-line stack traces from user-space with perf 2021-02-04 21:55:45 +01: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: Replace deprecated CPU-hotplug functions. 2021-08-05 10:57:01 +02:00
prom.c MIPS: replace add_memory_region with memblock 2020-10-12 12:01:36 +02:00
ptrace.c Revert "MIPS: Add basic support for ptrace single step" 2021-02-18 11:57:44 +01: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 arch: mips: update references to current linux-mips list 2021-02-23 13:24:38 +01:00
r4k_fpu.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
r4k_switch.S
r2300_fpu.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
r2300_switch.S
relocate.c kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
relocate_kernel.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01: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: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
scall64-n32.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
scall64-n64.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
scall64-o32.S MIPS: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01:00
segment.c
setup.c mips: setup: fix setnocoherentio() boolean setting 2022-03-08 19:12:48 +01:00
signal-common.h
signal.c entry: rseq: Call rseq_handle_notify_resume() in tracehook_notify_resume() 2021-09-22 10:24:01 -04: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: smp-bmips: fix CPU mappings 2021-03-06 08:43:39 +01:00
smp-cmp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 182 2019-05-30 11:29:20 -07:00
smp-cps.c MIPS: No need to check CPU 0 in cps_cpu_disable() 2020-12-28 22:34:09 +01: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 MIPS: smp: fill in sibling and core maps earlier 2022-03-19 13:47:48 +01:00
spinlock_test.c mips: kernel: use DEFINE_DEBUGFS_ATTRIBUTE with debugfs_create_file_unsafe() 2021-03-14 14:09:49 +01:00
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: Fix build error due to PTR used in more places 2022-02-16 12:56:16 +01: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 arch/mips/kernel/traps: use vma_lookup() instead of find_vma() 2021-06-29 10:53:51 -07:00
unaligned.c MIPS: Fix new sparse warnings 2021-04-07 16:11:05 +02:00
uprobes.c MIPS: Return true/false (not 1/0) from bool functions 2021-08-21 10:37:30 +02:00
vdso.c MIPS: Add support for CONFIG_DEBUG_VIRTUAL 2021-04-06 14:34:02 +02:00
vmlinux.lds.S MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned 2021-03-16 22:53:08 +01:00
vpe-cmp.c mips: pci: convert comma to semicolon 2020-12-28 22:33:43 +01:00
vpe-mt.c mips: kernel: convert comma to semicolon 2020-12-28 22:32:28 +01:00
vpe.c MIPS: vpe: Remove vpe_getcwd 2021-01-27 21:49:16 +01:00
watch.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00