Skip to content

Commit 7cdda85

Browse files
ChangSeokBaebp3tk0v
authored andcommitted
x86/microcode: Introduce staging step to reduce late-loading time
As microcode patch sizes continue to grow, late-loading latency spikes can lead to timeouts and disruptions in running workloads. This trend of increasing patch sizes is expected to continue, so a foundational solution is needed to address the issue. To mitigate the problem, introduce a microcode staging feature. This option processes most of the microcode update (excluding activation) on a non-critical path, allowing CPUs to remain operational during the majority of the update. By offloading work from the critical path, staging can significantly reduce latency spikes. Integrate staging as a preparatory step in late-loading. Introduce a new callback for staging, which is invoked at the beginning of load_late_stop_cpus(), before CPUs enter the rendezvous phase. Staging follows an opportunistic model: * If successful, it reduces CPU rendezvous time * Even though it fails, the process falls back to the legacy path to finish the loading process but with potentially higher latency. Extend struct microcode_ops to incorporate staging properties, which will be implemented in the vendor code separately. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Chao Gao <chao.gao@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Tested-by: Anselm Busse <abusse@amazon.de> Link: https://lore.kernel.org/20250320234104.8288-1-chang.seok.bae@intel.com
1 parent ed44a56 commit 7cdda85

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,17 @@ static int load_late_stop_cpus(bool is_safe)
589589
pr_err("You should switch to early loading, if possible.\n");
590590
}
591591

592+
/*
593+
* Pre-load the microcode image into a staging device. This
594+
* process is preemptible and does not require stopping CPUs.
595+
* Successful staging simplifies the subsequent late-loading
596+
* process, reducing rendezvous time.
597+
*
598+
* Even if the transfer fails, the update will proceed as usual.
599+
*/
600+
if (microcode_ops->use_staging)
601+
microcode_ops->stage_microcode();
602+
592603
atomic_set(&late_cpus_in, num_online_cpus());
593604
atomic_set(&offline_in_nmi, 0);
594605
loops_per_usec = loops_per_jiffy / (TICK_NSEC / 1000);

arch/x86/kernel/cpu/microcode/internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ struct microcode_ops {
3131
* See also the "Synchronization" section in microcode_core.c.
3232
*/
3333
enum ucode_state (*apply_microcode)(int cpu);
34+
void (*stage_microcode)(void);
3435
int (*collect_cpu_info)(int cpu, struct cpu_signature *csig);
3536
void (*finalize_late_load)(int result);
3637
unsigned int nmi_safe : 1,
37-
use_nmi : 1;
38+
use_nmi : 1,
39+
use_staging : 1;
3840
};
3941

4042
struct early_load_data {

0 commit comments

Comments
 (0)