Tuesday 19 July 2016

Initrmfs generator for kdump

Creating a initramfs generator was a part of my GSOC project.

A initramfs is basically a image which is used before root file system get mounted. The kernel simply extract image and uses it as early file system. It sometime contains Microcode for processors. The microcode is applied during boot. The initramfs is basically for advanced users. It's not compulsory. It contains the directory structure of a linux system. It contains any user space utilities, device drivers and mainly the "init" binary which prepares the system. The user generally uses a custom init by help of tools like systemd, which behaved like init. It uses cpio newc format archive as initramfs. This can also be compressed using formats like gzip. This cpio supports device nodes.

For kdump our initramfs's job is to take the dump from /proc/vmcore and save it. The current initramfs for kdump in fedora contains a lot of things which are unnecessary for our purpose. Our job is to create the minimal initramfs.

For this we have to include the necessary things. The systemd unit configuration files, makedumpfile, busybox, usb storage drivers (it takes dump in usb thumb drive). That's what I found necessary till now.

Current kdump user space tool uses dracut for this purpose. dracut puts the necessary things in a folder and creates a cpio archive out of this. Our kdump user space tool puts the necessary things in that temporary folder.
It takes some help of dracut (using dracut functions) for this.


dracut takes modular approach. All the things we want to put in initramfs is in some dracut module. That way dracut can easily takes the decision what to put in the initramfs. The module must include a setup script called module-setup.sh which contains the functions check, install, installkernel which defines if the modules will be included or not and the functionality of modules.

Current kexec tool inserts the extra things (makedumpfile, systemd unit config files etc) which are not present in dracut inbuilt modules by creating a dracut module called 99kdumpbase.

Monday 11 July 2016

Problems with kdump runtime memory allocation patch

After creating the kdump run time memory allocation patch using CMA (Contiguous memory allocator) framework we got review from some members of linux kernel community. They mentioned some issues with CMA.

*CMA doesn't work as it should work. It fails to allocate memory from a CMA area sometime. As, kernel can pin the movable pages (directly or using reference count). This will make the pages temporarily unmovable. hence, CMA fails to allocate memory.

https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org/thread/V4T3QOKEUT4EYUWB3G44SIEJGFI42FQO/

https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org/thread/7KFUPRFNIB7BIS6JCUJ4AVH5YURSIKAJ/

People are trying to solve this problems their own way. Companies using some modified version of CMA for their purpose. There is not any solution to the mainline yet.