x86/cache: Restore AP cache state while bringing CPUs online on resume
PATCH 1/1 x86/cache: Restore AP cache state while bringing CPUs online on resume
Some platform firmware, including that of Intel Macs, leaves the APs with an invalid MTRR state after resume. x86 delays the AP cache initialization until all APs are online, so an affected AP runs uncached through its bring-up. On a Core i9 MacBook Pro a resume can take up to a minute.
Drop the x86 thaw hooks so that cache_ap_online() restores the MTRR and PAT state of each AP as it comes online, as on CPU hotplug. The APs then come online right away. Boot keeps the delayed initialization.
Tested on a MacBookAir9,1, MacBookPro15,1 and MacBookPro16,1.
--- arch/x86/kernel/smpboot.c | 10 ---------- 1 file changed, 10 deletions(-)
arch/x86/kernel/smpboot.c +0 -10
@@ -1251,16 +1251,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)snp_set_wakeup_secondary_cpu (); } -void arch_thaw_secondary_cpus_begin (void ) -{ -set_cache_aps_delayed_init (true); -} - -void arch_thaw_secondary_cpus_end (void ) -{ -cache_aps_init (); -} -/* * Early setup to make printk work. */
base-commit: c6279551a44c06f4cb1f7b1df2fb8e0d6d6e54cd
Hi,
gentle ping on this patch. Is there anything you would like me to change?
Andre
Borislav Petkov
maintainerQuoted 2 lines · Andre Eikmeyer
gentle ping on this patch. Is there anything you would like me to change?
Yes, why is your change correct for all x86 out there?
Yu Chen in his original patch at least tried to do some git archeology, you're simply axing them off because works-for-me.
Sorry.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 6 lines · On Fri, 27 Nov 2026 17:18:42 -0800 Borislav Petkov <[email protected]> wrote:
Yes, why is your change correct for all x86 out there?
Yu Chen in his original patch at least tried to do some git archeology, you're simply axing them off because works-for-me.
Sorry.
Hi Boris,
No worries, I get you. I should have provided more background info. I am not trying to axe them off. I could simply use your help.
The patch refers to this discussion with Lukas and Chen Yu on a patch I sent for early CPU offlining on T2 Macs
https://lore.kernel.org/all/[email protected]/
This is what I found in the history
- d0af9eed5aa9 made each AP init a stop_machine() rendezvous as the SDM requires. Boot and resume delay the AP init until all APs are up. So one rendezvous covers all of them.
- The delay assumes that the APs come back from S3 with usable MTRRs. Some firmware leaves them uncached and each AP then runs uncached until thaw_secondary_cpus() ends. Lukas saw this on his older Macbook Pro 9,1, I see it on the T2 Macs.
- Chen Yu's v4 from 2018 did one rendezvous per AP on resume and reprogrammed only the incoming CPU. It slipped through the cracks.
- Since 0b9a6a8bedb, a rendezvous outside the delayed phase reprograms only the incoming CPU. Without the thaw hooks resume takes the same path as CPU hotplug.
You will agree that a resume from S3 taking longer than rebooting is annoying. Especially on a portable device. It's getting worse the more cores a CPU has. Like exponentially worse. We see 30 seconds on a 10th gen I5 and around 3 minutes on a Coffee Lake I9.
However, the only drawback I see is one rendezvous per AP instead of one for all. I can only test what the T2 community and I have. If this has a downside on systems that are not affected, please point me to it. As is, the patch is small and fixes our stuff, from what I thought was a good thing to begin with. And we could go from here.
Best,
Andre