问题现象
qemu在启动linux系统时(busybox制作的initramfs),可能会在smpboot处卡住,然后等了好久,会出现打印如下:
[ 0.000000] smpboot: CPU 1 Converting physical 0 to logical die 1
...这里会卡住等待好久...
[ 0.000000] calibrate_delay_direct() dropping max bogoMips estimate 0 = 84921118288
[ 0.000000] calibrate_delay_direct() dropping max bogoMips estimate 1 = 74286728978
[ 0.000000] calibrate_delay_direct() dropping max bogoMips estimate 3 = 16816095840
[ 0.000000] calibrate_delay_direct() dropping max bogoMips estimate 4 = 9257731229
[ 0.000000] calibrate_delay_direct() failed to get a good estimate for loops_per_jiffy.
[ 0.000000] Probably due to long platform interrupts. Consider using "lpj=" boot option.
[ 0.294752] smp: Brought up 1 node, 2 CPUs
[ 0.295035] smpboot: Max logical packages: 2
问题原因
查找网上资源,说是因为未设置“lpj启动参数”,导致内核在估算loops_per_jiffy,从而耽误了时间。
解决方法
在启动参数中加了个lpj变量(变量值随意设定的)
/src/qemu-5.1.0/build/x86_64-softmmu/qemu-system-x86_64 \
-kernel /project/${kpath}/arch/x86_64/boot/bzImage \
-initrd /project/initramfs.igz \
-smp 2 -nographic -append "nokaslr earylyprintk=serial,ttyS0 console=ttyS0 lpj=800000" $para
然后确实不会卡主在smpboot那里了: