Preface
This book, in its second edition now, has been explicitly written with a view to helping you learn Linux kernel development in a practical, hands-on fashion, along with the necessary theoretical background to give you a well-rounded view of this vast and interesting topic area. It deliberately focuses on kernel development via the powerful Loadable Kernel Module (LKM) framework; this is because the vast majority of real-world/industry kernel projects and products, which includes device driver development, are done in this manner.
The focus is kept on both working hands-on with, and understanding at a sufficiently deep level, the internals of the Linux OS. In this regard, we cover everything from building the Linux kernel from source to understanding and working with complex topics such as synchronization within the kernel.
To guide you on this exciting journey, we divide this book into three sections. The first section covers the basics – setting up an appropriate workspace for kernel development, building the modern kernel from source, and writing your first kernel module.
The next section, a key one, will help you understand essential kernel internals details; its coverage includes the Linux kernel architecture, the task structure, user - and kernel-mode stacks, and memory management. Memory management is a key and interesting topic – we devote three whole chapters to it (covering the internals to a sufficient extent, and importantly, how exactly to efficiently allocate and free kernel memory). The internal working and deeper details of CPU (task) scheduling on the Linux OS round off this section.
The last section of the book deals with the more advanced topic of kernel synchronization – a necessity for professional design and code on the Linux kernel. We devote two whole chapters to covering key topics here.
The book uses the kernel community’s 6.1 Long Term Support (LTS) Linux kernel. It’s a kernel that will be maintained (both bug and security fixes) from December 2022 right through to December 2026. Moreover, the CIP (Civil Infrastructure Project) has adopted 6.1 as an SLTS (Super LTS) release and plans to maintain it for 10 years, until August 2033! This is a key point, ensuring that this book’s content remains current and valid for years to come!
We very much believe in a hands-on approach: some 40 kernel modules (besides several user apps and shell scripts, double that of the first edition!) in this book’s GitHub repository make the learning come alive, making it fun, practical, interesting, and useful.
We highly recommend you also make use of this book’s companion guide, Linux Kernel Programming Part 2 – Char Device Drivers and Kernel Synchronization: Create user-kernel interfaces, work with peripheral I/O, and handle hardware interrupts. It’s an excellent industry-aligned beginner’s guide to writing misc
character drivers, performing I/O on peripheral chip memory, and handling hardware interrupts. You can get this book for free along with your print copy; alternately, you can also find this eBook in the GitHub repository at https://github.com/PacktPublishing/Linux-Kernel-Programming/tree/master/Linux-Kernel-Programming-(Part-2).
We really hope you learn from and enjoy this book. Happy reading!