Thursday, September 1, 2022

[SOLVED] Why does the Linux kernel panic pin the CPU at 100%?

Issue

Take a look at the following:

qemu-system-x86_64 -kernel /boot/vmlinuz-linux

This will cause a kernel panic, as expected (there is no init). Much less expected is that it causes one processor core to spin until qemu is killed. Why is this? What exactly causes the kernel to leave the CPU in this state?


Solution

Why does the Linux kernel panic pin the CPU at 100%?

This loop https://code.woboq.org/linux/linux/kernel/panic.c.html#74 :

while (1)
    cpu_relax();


Answered By - KamilCuk
Answer Checked By - Terry (WPSolving Volunteer)