Linux kernel workqueues: Is it OK for the worker function to kfree its own work item?

Freeing yourself Working with Linux kernel’s workqueues, I incremented a kref reference count before queuing a work item, in order to make sure that the data structure that it operated on will still be in memory while it runs. Just before returning, the work item’s function decremented this reference count, and as a result, the [...]

Installing GRUB 2 manually with rescue-like techniques

Introduction It’s rarely necessary to make an issue of installing and maintaining the GRUB bootloader. However, for reasons explained in a separate post, I wanted to install GRUB 2.12 on an old distribution (Debian 8). So it required some acrobatics. That said, it doesn’t limit the possibility to install new kernels in the future etc. [...]

Migrating an OpenVZ container to KVM

Introduction My Debian 8-based web server had been running for several years as an OpenVZ container, when the web host told me that containers are phased out, and it’s time to move on to a KVM. This is an opportunity to upgrade to a newer distribution, most of you would say, but if a machine [...]

Google Pixel 6 Pro: Limiting the battery’s charge level

Introduction This post is a spin-off from another post of mine. It’s the result of my wish to limit the battery’s charge level, so it doesn’t turn into a balloon again. I’ve written this post in chronological order (i.e. in the order that I found out things). If you’re here for the “what do I [...]

dmesg output of a Google Pixel 6 Pro

Just in case this helps anyone, this is the output of the dmesg command. The phone was rooted with Magisk, or else how would I get this? But at this stage, I hadn’t install Zygisk or any other module to hide the fact that the phone is rooted. Note that there’s also logcat for the [...]

Setting up a small Sphinx project for validating Linux kernel documentation RST markup

Introduction Since I maintain a module in the Linux kernel, I also need to maintain its documentation. Sometime in the past, the rst format was adopted for files under Documentation/ in the kernel tree, with Sphinx chosen as the tool for making formatted documents. Which is pretty nice, as rst human readable and can also [...]

Linux kernel: Dumping a module’s content for regression check

After making a lot of whitespace reorganization in a kernel module (indentation, line breaks, fixing things reported by sparse and checkpatch), I wanted to make sure I didn’t really change anything. All edits were of the type that the compiler should be indifferent about, but how can I be sure I didn’t change anything accidentally? [...]

Root over NFS remains read only with Linux v5.7

Upgrading the kernel should be quick and painless… After upgrading the kernel from v5.3 to 5.7, a lot of systemd services failed (Debian 8), in particular systemd-remount-fs: ● systemd-remount-fs.service – Remount Root and Kernel File Systems Loaded: loaded (/lib/systemd/system/systemd-remount-fs.service; static) Active: failed (Result: exit-code) since Sun 2020-07-26 15:28:15 IDT; 17min ago Docs: man:systemd-remount-fs.service(8) http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems Process: [...]

Linux kernel OOPS dissection notes

What’s this Every now and then I find myself looking at an Oops or kernel panic, reminding myself how to approach this. So this is where I write down the jots as I go. This isn’t very organized. Disassembly First thing first: Disassemble the relevant parts: $ objdump -DS driver.ko > ~/Desktop/driver.asm Doing this on [...]

Ftrace: The Linux kernel hacker’s swiss knife

Introduction I ran into ftrace completely by chance, while trying to figure out why the call to usb_submit_urb() took so long time. In fact, it wasn’t. It was pr_info() that delayed the output. And it was ftrace that got me to realize that. Whether you’re into dissecting existing kernel code, and want to know which [...]