A Linux ECS instance may restart abnormally when the kernel parameter kernel.unknown_nmi_panic is set to 1. This article explains the cause and provides steps to resolve the issue.
Problem description
After you set the kernel parameter kernel.unknown_nmi_panic on a Linux ECS instance, the instance restarts abnormally. After the system recovers, the kernel log shows the following call stack:
[5912557.130943] Uhhuh. NMI received for unknown reason 20 on CPU 0.
[5912557.131115] Do you have a strange power saving mode enabled?
[5912557.131287] Kernel panic - not syncing: NMI: Not continuing
Cause
A Non-Maskable Interrupt (NMI) is a hardware interrupt that the CPU cannot ignore or defer. The Linux kernel sometimes receives NMIs from unknown sources. These are typically harmless and do not indicate actual hardware failure.
The kernel parameter kernel.unknown_nmi_panic controls how the kernel responds to an unknown NMI. When set to 1, the kernel treats any unknown NMI as a system error, triggers a kernel panic, and restarts the instance. Most Linux distributions set this parameter to 0 by default, which means the kernel ignores unknown NMIs.
| Value | Behavior |
|---|---|
1 |
The kernel triggers a kernel panic when it receives an unknown NMI. This causes unexpected instance restarts or service interruptions. |
0 |
The kernel ignores the unknown NMI. The instance continues running. |
Solution
Set kernel.unknown_nmi_panic to 0 to prevent the kernel from panicking on unknown NMIs.
-
Log on to the ECS instance.
For more information, see Connect to a Linux instance by using a password or key.
-
Check whether any existing configurations set the
kernel.unknown_nmi_panicparameter.grep 'kernel.unknown_nmi_panic' /etc/sysctl.conf /etc/sysctl.d/*.conf-
If configurations exist, delete the redundant entries and keep only one entry in
/etc/sysctl.conf. Set the value to0:kernel.unknown_nmi_panic = 0 -
If no configuration exists, add
kernel.unknown_nmi_panic = 0to the end of/etc/sysctl.conf:sudo sh -c "echo >> /etc/sysctl.conf" sudo sh -c "echo 'kernel.unknown_nmi_panic = 0' >> /etc/sysctl.conf"
-
-
Apply the configuration.
sudo sysctl -pNoteTo change the parameter value without reloading the configuration file, run
sysctl -w kernel.unknown_nmi_panic=0instead. -
Verify that the parameter is set correctly.
sysctl kernel.unknown_nmi_panicExpected output:
kernel.unknown_nmi_panic = 0If the output shows
kernel.unknown_nmi_panic = 0, the fix is applied. The instance will no longer restart when it receives an unknown NMI.