Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Linux Kernel Programming
  • Toc
  • feedback
Linux Kernel Programming

Linux Kernel Programming

By : Kaiwan N. Billimoria
4.9 (35)
close
Linux Kernel Programming

Linux Kernel Programming

4.9 (35)
By: Kaiwan N. Billimoria

Overview of this book

The 2nd Edition of Linux Kernel Programming is an updated, comprehensive guide for new programmers to the Linux kernel. This book uses the recent 6.1 Long-Term Support (LTS) Linux kernel series, which will be maintained until Dec 2026, and also delves into its many new features. Further, the Civil Infrastructure Project has pledged to maintain and support this 6.1 Super LTS (SLTS) kernel right until August 2033, keeping this book valid for years to come! You’ll begin this exciting journey by learning how to build the kernel from source. In a step by step manner, you will then learn how to write your first kernel module by leveraging the kernel’s powerful Loadable Kernel Module (LKM) framework. With this foundation, you will delve into key kernel internals topics including Linux kernel architecture, memory management, and CPU (task) scheduling. You’ll finish with understanding the deep issues of concurrency, and gain insight into how they can be addressed with various synchronization/locking technologies (e.g., mutexes, spinlocks, atomic/refcount operators, rw-spinlocks and even lock-free technologies such as per-CPU and RCU). By the end of this book, you’ll have a much better understanding of the fundamentals of writing the Linux kernel and kernel module code that can straight away be used in real-world projects and products.
Table of Contents (16 chapters)
close
14
Other Books You May Enjoy
15
Index

What’s been added in the second edition?

A pretty huge amount of new material has been added into this, the Second Edition of the Linux Kernel Programming book. As well, being based on the very recent (as of this writing) 6.1 LTS release, its information and even code will remain industry-relevant for many, many years to come.

Here’s a quick chapter-wise summarization of what’s new in this second edition:

  • Materials updated for the 6.1 LTS kernel, maintained until December 2026, and until August 2033 via the CLP (6.1 SLTS)!
  • Updated, new, and working code for the 6.1 LTS kernel
  • Several new info-rich sections added to most chapters, many new diagrams, and new code examples to help explain concepts better
  • Chapter 1, Linux Kernel Programming – A Quick Introduction
    • Introduction to the book
  • Chapter 2, Building the 6.x Linux Kernel from Source – Part 1
    • The new LTS kernel lifetime mandate
    • More details on the kernel’s Kconfig+Kbuild system
    • Updated approaches on configuring the kernel
  • Chapter 3, Building the 6.x Linux Kernel from Source – Part 2
    • More details on the initramfs (initrd) image
    • Cross-compiling the kernel on an x86_64 host to an AArch64 target
  • Chapter 4, Writing Your First Kernel Module – Part 1
    • new-ish printk indexing feature covered
    • Powerful kernel dynamic debug feature introduced
    • Rate-limiting macros updated (deprecated ones not used)
  • Chapter 5, Writing Your First Kernel Module – Part 2
    • A better, ‘better’ Makefile (v0.2)
  • Chapter 6, Kernel Internals Essentials – Processes and Threads
    • New linked list demo module
  • Chapter 7, Memory Management Internals – Essentials
    • New coverage on how address translation works (including diagrams)
  • Chapter 8, Kernel Memory Allocation for Module Authors – Part 1
    • Coverage on using the “exact” page allocator API pair
    • FAQs regarding (slab) memory usage and their answers
    • The graphing demo (via gnuplot) is now automated and even saved to an image file, via a helper script
    • Finding internal fragmentation (wastage) within the kernel
  • Chapter 9, Kernel Memory Allocation for Module Authors – Part 2
    • Extracting useful information regarding slab caches
    • A word on slab shrinkers
    • Better coverage on the OOM killer (and systemd-oomd) and how it’s triggered; includes a flowchart depicting demand-paging and possible OOM killer invocation
    • Better coverage on kernel page reclaim, as well as the new MGLRU and DAMON technologies
  • Chapter 10, The CPU Scheduler – Part 1
    • New coverage on CFS scheduling period and timeslice. Coverage on the thread_info structure as well
    • New: the preempt dynamic feature
    • Enhanced coverage on exactly how and when schedule() is invoked
  • Chapter 11, The CPU Scheduler – Part 2
    • Much more depth in the powerful cgroups (v2) coverage plus an interesting script to let you explore its content
    • Leveraging the cgroups v2 CPU controller via both systemd and manually to perform CPU bandwidth allocation
    • A note on Google’s ghOSt OS
  • Chapter 12, Kernel Synchronization – Part 1
    • A new intro to the LKMM (Linux Kernel Memory Model)
    • More on locking plus deadlock avoidance guidelines
  • Chapter 13, Kernel Synchronization – Part 2
    • Expanded coverage on CPU caching and cache effects
    • New coverage on the powerful lock-free RCU synchronization technology
  • Online Chapter, Kernel Workspace Setup
    • Fixed errors in package names and versions
    • Ubuntu-based helper script that auto-installs all required packages

Most (if not all) earlier code errors, typos, and URLs are now fixed, based on prompt feedback, raising Issues/PRs on the book’s GitHub repo, from you, our wonderful readers!

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete