Repository navigation
arm64: spin table: close the holding pen behind each released CPU (deep-sleep wake panic) - #2192
m0d16l14n1 wants to merge 1 commit into
Conversation
|
Tested on J813 as the first commit of #2193 (head 8e270f6 on
|
|
Blockers: 1. The ordering is sound.
HW row: J815 (2 deep sleeps, burst start) and J813 (8 deep sleeps) cover the new path. The smp.c hunk is generic arm64, so also boot one plain spin-table Mac (M1 or M2) on this kernel with all CPUs online. Add the regression line for the J815 run: 0 failed units, 0 SELinux denials, 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
secondary_holding_pen_release is written with a CPU's MPIDR to let it out of the pen and never reset, so after boot it still names the last CPU released. secondary_data.task likewise keeps that CPU's idle task: __cpu_up() only clears it on failure. With the restartable spin table (aurora,rvbar-spin-table) a CPU comes back through the pen whenever the SoC restarts it at its reset vector: after a system sleep's commit, and at the wake. The CPU whose MPIDR is still in the pen walks straight through into secondary_startup, ahead of its own bring-up, and runs secondary_start_kernel() as that CPU with the stale task. The hotplug state machine has not started it, so no STARTING callback runs (no arch timer, no tick device), yet it marks itself online and completes cpu_running, so the real bring-up returns at once. It idles quietly while cpuidle is paused and faults at the first menu_select() after cpuidle_resume(): Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 CPU: 9 UID: 0 PID: 0 Comm: swapper/9 pc : tick_nohz_get_sleep_length+0x68/0xd4 Call trace: tick_nohz_get_sleep_length+0x68/0xd4 (P) menu_select+0x414/0x774 cpuidle_select+0x1c/0x28 do_idle+0x1e8/0x310 cpu_startup_entry+0x34/0x38 secondary_start_kernel+0x198/0x1bc Kernel panic - not syncing: Attempted to kill the idle task! Seen on a J815 (MacBook Air 15" M5) when every core was started at the end of the wake, as macOS does, instead of one by one at its bring-up. Reset the release to INVALID_HWID in the released CPU's cpu_postboot, which runs before complete(&cpu_running), so it can't race with the next bring-up; and again before a suspend's hold and after the wake, before any CPU is started. Clear secondary_data.task after a successful bring-up too, as kernels before 5.x did, so a core that still reaches __secondary_switched without a bring-up of its own waits in __secondary_too_slow instead of running as another CPU. Tested on J815: two real deep sleeps (256 s and 172 s) with all nine secondary cores started together at the wake, all back online, where the same kernel without this change panicked on the first wake. Signed-off-by: Nick <nekreshen@yandex.ru>
3cf4478 to
c5daf57
Compare
|
@RyanTheTide fixed: one human Rebased onto cc14570, and Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-review of c5daf57: No blockers. Earlier point 1 resolved: the commit has one human Signed-off-by and no co-author trailer, and the PR body ends with HW row (still owed): one plain spin-table Mac (M1 or M2) booted on this kernel with all CPUs online, since the smp.c hunk is generic arm64; and the regression line for the J815 run: 0 failed units, 0 SELinux denials, 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
|
The holding-pen change is still needed. Head |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at c5daf57. Clearing the release word in postboot closes the pen before the secondary publishes cpu_running. Clearing the task after the CPU-online check leaves the failed bring-up path intact. This changes the generic arm64 task publication as well as the Apple reset-vector path. Keep the reported deep-sleep row separate from a plain J413 cold boot that checks all CPUs online and a short resume regression. The host check is green.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at c5daf572c69cf596d254050089476e9793f67e53 against integration/aurora (70a00e583b03):
The synchronization and ordering in the patch are sound and still needed on integration/aurora (merges cleanly, CI host-tests green):
smp_rvbar_spin_table_postboot()resetssecondary_holding_pen_releasetoINVALID_HWIDbeforeset_cpu_online()andcomplete(&cpu_running)insecondary_start_kernel(), so it cannot race with the boot CPU's nextwrite_pen_release(mpidr).spin_table_hold_parked()andspin_table_stop_finished()close the suspend-commit and wake windows before any secondary is started.- Clearing
secondary_data.taskin__cpu_up()aftercpu_online(cpu)is safe because__secondary_switchedalready consumedsecondary_data.taskbeforesecondary_start_kernel()could completecpu_running.
Checklist findings:
- §1 No model gating: PASS on gating (zero chip/board/firmware gates), but note cross-Mac coverage below because the
arch/arm64/kernel/smp.chunk runs on every Apple Silicon Mac (including plainspin-tableM1/M2). - §2 Production-ready, no hacks: PASS. Default command line, no sleeps/retries or parameters.
- §3 Safety: PASS. Prevents a real NULL-deref wake panic.
- §4 Clean-room & attribution: PASS. Commit
c5daf572c69ccarries human author/committer (Nick <nekreshen@yandex.ru>) and a single humanSigned-off-by:with zero AI trailers; PR body ends withAssisted-by:. - §5 Evidence: BLOCKER (still owed). J815 (2 deep sleeps) and J813 (8 deep sleeps via #2193) cover the
aurora,rvbar-spin-tablewake path, but the two hardware items explicitly listed as still owed in the PR body remain open:- One plain
spin-tableMac (M1 or M2) cold-booted with this change verifying all CPUs come online cleanly (covering the genericarch/arm64/kernel/smp.chunk). - The full §5 regression line for the J815 run (0 SELinux denials, 0 failed units, 0 new kernel errors).
- One plain
- §6 Naming: PASS.
Non-blocking edge-case note: in smp_rvbar_spin_table_cpu_boot(), write_pen_release(mpidr) runs before spin_table_power->cpu_on(mpidr), and __cpu_up() returns early on a boot_secondary() error without clearing secondary_data.task — if cpu_on() ever fails, both the pen release and secondary_data.task remain set until the next bring-up or sleep hold. Resetting them on the cpu_on() error path would tighten that corner case, though it is not a merge blocker.
Posting the plain spin-table (M1/M2) control boot and the J815 regression line will clear this PR.
Assisted-by: LLM (Gemini 4 Neon)
The spin-table holding pen is never closed after a CPU is released. After boot,
secondary_holding_pen_releasestill holds the last CPU's MPIDR, andsecondary_data.taskstill holds its idle task (__cpu_up()only clears it on failure).With the restartable spin table (
aurora,rvbar-spin-table), a CPU comes back through the pen whenever the SoC restarts it at its reset vector: after a sleep's commit, and at the wake. The CPU whose MPIDR is still in the pen goes straight through it, ahead of its own bring-up:secondary_start_kernel()as that CPU, with no STARTING callbacks run, so it has no tick device.menu_select()aftercpuidle_resume().The J815 hit this when every core was started together at the end of the wake, as macOS does (the next PR in this series). The same stale value can let a core through after the commit too, because the pen checks the release before
secondary_pen_deep.Change
INVALID_HWIDincpu_postboot. That runs beforecomplete(&cpu_running), so it can't race with the next bring-up.secondary_data.taskis cleared after a successful bring-up, as before 5.x, so a stray core parks in__secondary_too_slow.Tested on J815 (MacBook Air 15" M5):
integration/auroracc14570:W=1adds no warnings inarch/arm64/kernel/.checkpatch --strictgives one warning, for the quoted oops line in the commit message, which is kept unwrapped.J813 (sithglan, gig3m): 8 deep sleeps with this as the first commit of #2193, in their comments there.
Still owed (HW rows): the
smp.chunk is generic arm64, so one plain spin-table Mac (M1 or M2) booted on this kernel with all CPUs online; and the regression line for the J815 run (0 failed units, 0 SELinux denials, 0 new kernel errors).Part of the J815 bring-up; board results are summarised in #135.
Assisted-by: LLM (Claude:Opus 5.5)