1. 引入
在一台linux机器上工作,没敲入任何命令,但命令行里突然出现 “kernel:NMI watchdog: BUG: soft lockup - CPU#8 stuck for 28s! [xsoftdd/12:0]” 这样的报错,如下图所示:
报错后,又能正常在命令行里运行命令了。
这是怎么回事呢?
2. soft lockup
在google上查到soft lockup相关的解释(参考3):
A soft lockup is the symptom of a task or kernel thread using and not releasing a CPU for a longer period of time than allowed.
The technical reason behind a soft lock involves CPU interrupts and nmi-watchdog. For each online CPU on the system, a watchdog process gets created. This kernel thread is created with highest scheduling priority possible.
可以看出,报错为soft lockup,就是说某个线程长期占用CPU不释放。
soft lockup是内核软死锁,是内核级别的问题。CPU负载时间过长,CPU电压不稳定,磁盘I/O过高等情况都可能引发soft lockup。可能的原因详见参考2。
3. 如何解决
笔者的情况是,只提示了上图中的一些信息,然后就没有任何报错了,系统又能正常使用,不需要去解决这个问题。
如果情况严重,可从参考4中查看soft lockup发生的具体原理。参考2中也提供了修改watchdog_thresh默认值(具体含义见参考4)的方法来解决这个问题。