kexec and kdump allow restarting the Linux kernel without rebooting into the BIOS. kexec loads a new kernel into memory, while kdump facilitates debugging of crashed systems by loading a dump capture kernel. These features were introduced in Linux 2.6.13 and are currently supported on several platforms. Development is ongoing to support kexec/kdump for paravirtualized Xen guests. Future plans include enabling crash recovery across Xen and guest domains.
Developer Data Modeling Mistakes: From Postgres to NoSQL
kexec / kdump implementation in Linux Kernel and Xen hypervisor
1. kexec/kdump implementation in
Linux Kernel and Xen hypervisor
usage, history and current developments
Sponsored by:
&
2. Agenda
•What is kexec and kdump ?
•History of kexec/kdump development in Linux Kernel and Xen.
•Current developments.
•Future plans.
•Resources.
•Questions and Answers ?
3. What is kexec and kdump ?
•kexec and kdump are companions.
•kdump uses most of the code from kexec.
•kexec allows machine restart without jumping into BIOS.
•kdump eases kernel debugging when running system was crashed.
4. What is kexec ?
•kexec allows machine restart without jumping into BIOS.
•It greatly speeds up system initialization.
•kexec does not care about current system state.
•It is role of administrator to prepare system for restart.
•BIOS does not initialize the devices.
•Can lead to unpredictable state when devices were not properly
shutdown.
•Load specified kernel and other modules (if user requires it) into memory
(kexec -l|--load <kernel-image> …).
•Jump into initialization code which finally calls
new kernel (kexec -e|--exec …).
5. What is kdump ?
•kdump eases kernel debugging when running system was crashed.
•Requires reserved memory (say 128 MB) that cannot be touched.
•Ignores the current state of the machine - just tries to boot.
•Boot system with crashkernel option (Linux Kernel or
Xen hypervisor).
•Load specified crash kernel into previously reserved memory by
crashkernel option (kexec -p|--load-panic <kernel-image> …).
•… the system will reboot into the dump-capture kernel if a system crash is
triggered. Trigger points are located in panic(), die(), die_nmi() and in the
sysrq handler (ALT-SysRq-c). … (linux/Documentation/kdump/kdump.txt).
6. What is kdump ?
•New system running under dump-capture kernel expose raw image of
memory of crashed system through /dev/oldmem device interface.
•Through /proc/vmcore ELF format image of memory of crashed system is
available.
•ELF format image is useful for GDB and Crash tool.
•… Before analyzing the dump image, you should reboot into a stable kernel. …
(linux/Documentation/kdump/kdump.txt).
•kexec and kdump are excellent tools, albeit they have some shortcomings.
7. What is kexec and kdump ?
kexec/kdump infrastructure:
•kexec-tools - userspace tools.
•kexec/kdump implementation in Linux Kernel.
•kexec/kdump implementation in Xen.
8. Details of kexec load phase
•kexec -l|--load <kernel-image> …
•Compute a hash (SHA 256) of the loaded kernel.
•kexec calls sys_kexec_load().
•sys_kexec_load() loads kernel into memory and establishes
identity page tables for the kexec kernel.
•On Xen hypervisor dom0 kernel calls
HYPERVISOR_kexec_op(KEXEC_CMD_kexec_load, …)
hypercall which loads kernel into memory on behalf of dom0 kernel.
9. Details of kexec execution phase
•kexec -e|--exec …
•kexec calls sys_reboot() with LINUX_REBOOT_CMD_KEXEC cmd
argument which later calls kernel_kexec(),
•kernel_kexec() calls machine_kexec() which prepare
arguments for relocate_kernel() and calls it.
•On Xen hypervisor dom0 kernel does not call relocate_kernel()
directly. First of all it calls
HYPERVISOR_kexec_op(KEXEC_CMD_kexec, …) hypercall which
later calls relocate_kernel().
10. Details of kexec execution phase
•relocate_kernel() switch to identity page tables, relocate
kernel and then jump into purgatory code.
•purgatory code do some arch specific setup (vga reset, PIC init,
backup first 640K of memory on x86 platform if it is panic
kernel …).
•Verify a hash (SHA 256) of the loaded kernel established at load
phase and jump into kexec kernel.
•New kernel executes as usual.
11. History of kexec/kdump development in Linux Kernel and Xen
•kexec/kdump were introduced in Linux Kernel Ver. 2.6.13.
•Currently (Linux Kernel Ver. 3.0) kexec/kdump support is available on
eight platforms (ARM, IA-64, MIPS, PowerPC, S/390, SH, Tile, x86).
•kexec/kdump in Xen is available since Ver. 3.0.4.
•kexec/kdump under Xen dom0 is not available with paravirt kernel,
but it is with old style Xenlinux patches.
12. Current developments
•kexec/kdump implementation in Linux Kernel is quite stable.
•kexec/kdump implementation in Xen is quite stable too.
•Xenlinux kernels receiving only fixes (if any).
•kexec/kdump implementation for pvops Linux Kernel is under
development now.
•This work is sponsored by Google under Google Summer of
Code 2011 program.
13. Current developments
•Development is based off 2.6.32 Novell SLES11 Xen kexec/kdump
changes.
•Initial implementation patch (only for dom0) will be posted shortly
on Xen-devel and LKML.
•It requires a lot of cleanups.
•Currently there are more implementation questions than technical
ones.
•kexec-tools requires some modification also (will be posted shortly
on kexec@lists.infradead.org, Xen-devel and LKML).
14. Future plans
•kexec/kdump support for PV guest domains.
•kexec/kdump support for PVonHVM guest domains (some work is
done by Olaf Hering).
•kexec/kdump support for HVM guest domains - it works, however,
some cleanups would be required.
15. Future plans
Automatic Xen/dom0 kernel crash recovery:
•Xen or dom0 kernel crashing (guest domains were running).
•New incarnation of Xen hypervisor and dom0 kernel is started.
•Guest domains are restarted from point at which they were
running when Xen/dom0 kernel crash occurred.
16. Resources
•http://www.kernel.org/ - The Linux Kernel Archives
•ftp://ftp.kernel.org/pub/linux/utils/kernel/kexec/ - kexec-tools src
•git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git -
kexec-tools development tree
•kexec man page
•Linux Kernel source: linux/Documentation/kdump/
•http://www.xen.org/products/xenhyp.html - Xen Hypervisor
•http://xenbits.xen.org/ - Xen Source Repositories
•http://people.redhat.com/~anderson/ - Crash tool