For the book "Linux Kernel Programming", Kaiwan N Billimoria, Packt (Mar 2021).
Book GitHub repo: https://github.com/PacktPublishing/Linux-Kernel-Programming
Here, we present, in a chapter-wise format, additional online as well as book references. We feel that these will help you, the reader, in digging deeper into topics, or gaining additional views/information, or both. We definitely recommend you browse through the provided references. Also, you will find that some resources are repeated across chapters; we leave it this way so that you can gain all required resources in one place (and chapter-wise). (Obviously, these reference articles/blogs/etc are provided "as-is"; we cannot vouch for their correctness or validity).
For your convenience, below are chapter-wise links to the Further Reading notes:
-
Generic online and book resources : miscellaneous, very useful
-
Chapter 3, Building the 5.0 Linux kernel from Source, Part 2
-
Chapter 4, Writing your first Kernel Module - the LKM Framework, Part 1
-
Chapter 5, Writing your first Kernel Module - the LKM Framework, Part 2
-
Chapter 6, Kernel Internals Essentials - Processes and Threads
-
Chapter 8, Kernel Memory Allocation for Module Authors, Part 1
-
Chapter 9, Kernel Memory Allocation for Module Authors, Part 2
Don't forget: The companion book 'Linux Kernel Programming (Part 2): Writing character device drivers: Learn to work with user-kernel interfaces, handle peripheral I/O & hardware interrupts' is available as well! (Hey, the ebook is free!) - It's opensource GitHub repo is here.
Besides the Further Reading resource specified chapter-wise, be sure to refer to the "special" section below entitled Generic online and book resources : miscellaneous, very useful! These
links and books are considered to be useful throughout your journey through this book and after.
- The Linux kernel documentation
- Very useful! LWN (Linux weekly news) Kernel index
- Deprecated things: DON'T use 'em! Just say No; Deprecated Interfaces, Language Features, Attributes, and Conventions
A few excellent books that come to mind (specific books on the Linux kernel and writing Linux device drivers are mentioned in the appropriate chapter's Further reading section):
-
The Mythical Man Month, Frederick P Brooks
-
The Art of Unix Programming, Eric S Raymond (AW)
-
Programming Pearls, Jon Bentley
-
The Practice of Programming, Brian Kernighan and Rob Pike
-
The Pragmatic Programmer: From Journeyman to Master, Hunt and Thomas
-
The Joy of Linux, Hall and Proffitt
-
Hands-On System Programming with Linux, Kaiwan N Billimoria
-
Unix Network Programming, W. Richard Stevens
-
Unix Systems Programming: Communication, Concurrency and Threads, Robbins and Robbins
-
In general an excellent in-depth technical article: SO YOU WANT TO BUILD AN EMBEDDED LINUX SYSTEM?, Jay Carlson, Oct 2020 ; it covers an introduction to the whys and why-nots of using Linux on an embedded system, hardware and software design workflow, as well as a pretty detailed rundown on 10 CPUs/boards that run embedded Linux (with benchmarks)
-
Julia Evans' blog and zines:
-
Tip (reprodcued from Chapter 5): "Is there a really practical hands-on tip, an almost guaranteed way to become a kernel hacker? Of course, keep reading this book! Ha ha, yes, besides, do partake in the simply awesome Eudyptula Challenge. Hang on, it's - very unfortuantely, and as of this writing - closed down. Fear not, here's a site with all the challenges posted (and the solutions, don't cheat!); do check it out and try the challenges."
Resources on setting up a Linux guest using VirtualBox on a Windows host:
-
A very clearly written tutorial entitled Install Linux Inside Windows Using VirtualBox, Abhishek Prakash (It's FOSS!, August 2019)
-
An alternate, similarly excellent resource: Install Ubuntu on Oracle VirtualBox
-
Related – Easy Ways to Check If Your Processor Supports Virtualization
-
'Share Folders between Host and Guest OS in VirtualBox', S Butler, April 2020
Good resources on toolchains:
-
Cross-compilation toolchains for Linux, Bootlin Very user-friendly – simply select and download the toolchain of choice.
-
A wiki page (from the SEALS project I maintain, see the following) with instructions on downloading and installing the latest ARM Linaro toolchain (a popular one) is available here
-
Learn how to install many apps on Ubuntu/CentOS/Debian/etc via the Installi web guide
Some useful tooling, drivers, and so on, created by myself:
- The procmap utility - view any process's virtual address space fully (both user+kernel VAS): procmap
- Scripts, tools, utils, code : usefulsnips
- SEALS : Simple Embedded Arm Linux System
- device-memory-readwrite : Read/write pretty much any memory location (RAM or hardware IO memory) on a device or PC
Emulating a Raspberry Pi: - Emulating a Raspberry Pi on Linux
Code browsers - Ctags Tutorial - The Vim/Cscope tutorial
-
Official Kernel Documentation : the modern Linux kernel documentation is very well written and presented here
-
Git
- Firstly, A Gentle Introduction to Version Control
- Resources to Learn Git
- The “official” git website
- Try Git in your browser – interactive tutorial!
- Most commonly used git tips and tricks on github
- The "Git Magic" book, by Ben Lynn (PDF)
- Aha! Moments when learning Git
- How not to be afraid of Git anymore
- Getting Git Right, Atlassian.com
- ... and many more
-
LTSI Project update - Long Term Support Initiative – slide deck, Open Source Summit Japan, June 2018
-
Linux kernel versions with detailed notes on new features, kernelnewbies
-
Fun: Occurences of words in the Linux kernel source code over time
-
Licensing
- The differences between the GPL, LGPL and the BSD
- Proprietary loadable kernel modules, LWN
- Choose an open source license
- Legal Risks of Open Source – GPL/Linux Loadable Kernel Modules
- Linux kernel licensing rules
- To circumvent the EXPORT_SYMBOL_GPL(), people have been known to use a GPL "shim" kernel module whose routines are invoked from a proprietary module; Greg K Hartman 'Re: EXPORT_SYMBOL_GPL recursive for shim and/or wrapper
- MIT vs. BSD vs. Dual License
-
Detailed article: Exploring the Linux kernel: The secrets of Kconfig/kbuild
-
Article: How to compile a Linux kernel in the 21st century, S Kenlon, Aug 2019
-
Interesting: Meet the contributor of the 1-millionth commit: Ricardo Neri, Swapnil Bharatiya, Sept 2020
-
Initramfs (initrd):
- Opening and modifying the initrd
- Initramfs (on Ubuntu wiki)
- informative: debian bug report: intel-microcode: breaks initrd for newer kernels, Sept 2014
- distri: 20x faster initramfs (initrd) from scratch, Jan 2020
- Encrypting disks with LUKS and cryptsetup
-
How to Boot into Single User Mode in CentOS/RHEL 7, Kili, Tecmint, August 2017
-
Article: Linux Kernel Cross Compilation
-
Building the (usual 32-bit) kernel for the Raspberry Pi device
-
Building a 64-bit kernel for the Raspberry Pi
-
blog article: 'BUILD A 64-BIT KERNEL FOR YOUR RASPBERRY PI 3', Dec 2016
-
Interesting, an Ubuntu 18.04 server on Aarch64 Raspberry Pi; simplest way to get a 64-bit Raspberry Pi kernel and rootfs in a single image which can be burned onto the SD card
-
-
New Linux kernel: 'Linux 5.6 Is Looking Like It Will Be Spectacular With A Long List Of Features', Phoronix, 26Jan2020
- Official Kernel Documentation : kernel parameters
- 'How to get printk format specifiers right', Linux kernel doc
- 'What are the __init* and __exit* macros ?', kernelnewbies
- Systemd
- Linux console (on Wikipedia)
- Debugging by printing, eLinux
- Blog article: "MAKEFILES TUTORIAL", Liran B.H.
- Blog article: A Standalone Linux Kernel Module, Levinzon, Medium, May 2020
- BusyBox: The Swiss Army Knife of Embedded Linux
-
Blog article: WORKING ON THE CONSOLE WITH THE RASPBERRY PI, kaiwanTECH
-
Licensing
- Being honest with MODULE_LICENSE, Jon Corbet, LWN, Apr 2004
- Multi-licensing
- Dual Licensing: Having Your Cake and Eating It Too, LinuxInsider
- GPL License FAQs
- Selecting a license
-
Arithmetic Overflow
- An excellent must-read whitepaper: 'Understanding Integer Overflow in C/C++', Dietz, et al, June 2012
- 'Catch and compute overflow during multiplication of two large integers', StackOverflow
- An example of checking for arithmetic overflow in 'real-world' code can be found in the git codebase; see the wrapper.c code for usage examples
-
Article: 'Improving EXPORT_SYMBOL()', Jon Corbet, Feb 2016, LWN
-
StackOverflow Q&A: "How to prevent “error: 'symbol' undeclared here” despite EXPORT_SYMBOL in a Linux kernel module?"
-
Linux kernel static analysis
-
A book on static analysis with the opensource SonarQube tool: ['SonarQube in Action', G. Ann Campbell and Patroklos P. Papapetrou, Oct 2013] https://www.manning.com/books/sonarqube-in-action#toc
-
Blog article: "LINUX KERNEL DEVELOPMENT – KERNEL MODULE PARAMETERS", Liran B.H.
-
Useful Arch Linux Wiki on kernel module - gathering info, auto-loading, aliasing, blacklisting, etc: "Kernel module"
-
StackOverflow Q&A: "Where does modprobe load a driver that udev requests?"
-
DKMS: Dynamic Kernel Module Support
- AskUbuntu: "What does DKMS do? How do I use it?"
- dkms(8) man page](https://linux.die.net/man/8/dkms)
-
- The Kernel Self Protection Project (KSPP, Kees Cook)
- Regular updates on the state of kernel secuirty: codeblog, by Kees Cook
- Arch Linux wiki: "Security / Kernel hardening"
- "The status of kernel hardening", LWN, Nov 2016
- Blog article: "Effectively bypassing kptr_restrict on Android"
- Quora: "What are some of the best resources for Kernel exploitation on Linux?"
- Linux Kernel Exploitation GitHub blog - a long list of kernel exploitation resources
- "Hardened GNU/Linux - Linux kernel mitigation checklist"
- "Loading signed kernel modules", LWN, Dec 2011
- "Is My IoT Device Secure? 7 Questions You Should Be Asking Yourself Today", Jan 2020, DZone
-
The Eudyptula Challenge: "The Eudyptula Challenge was a series of programming exercises for the Linux kernel, that started from a very basic "Hello world" kernel module, moving on up in complexity to getting patches accepted into the main Linux kernel source tree." It's really cool but NOT active as of this writing though.
-
Book: Hands-On System Programming with Linux", Kaiwan N Billimoria, Packt. Prerequisites to this chapter (essential reading, really):
- Ch 1 : Linux System Architecture
- Ch 2 : Virtual Memory
-
CPU ABI, a blog article : APPLICATION BINARY INTERFACE (ABI) DOCS AND THEIR MEANING
-
[LWN kernel index on kernel stacks](https://lwn.net/Kernel/Index/#Kernel_ stack)
-
Blog article: Some Tricks used by the Linux kernel
-
[un]likely() macros:
-
[e]BPF – The modern approach to system/app tracing and performance analysis:
- Linux Extended BPF (eBPF) Tracing Tools, Brendan Gregg
- Learn eBPF Tracing: Tutorial and Examples (B Gregg)
- How eBPF Turns Linux into a Programmable Kernel, Jackson, October 2020
- (Kernel-level) A thorough introduction to eBPF, Matt Fleming, LWN, December 2017
- How io_uring and eBPF Will Revolutionize Programming in Linux, Glauber Costa, April 2020
- BPF Performance Tools, by Brendan Gregg – official repo
-
Kernel lockdown:
-
Books on Linux kernel memory management internals:
-
Deep detail on MM and paging on the Intel processors can be found in their excellent manuals here (Ch 4, Paging): Intel® 64 and IA-32 Architectures Software Developer’s Manual. Volume 3 (3A, 3B & 3C): System Programming Guide
-
On vsyscall, vdso and VVAR
-
'Linux Terminal: Check who uses all your memory with smem', Linuxaria, Oct 2013
-
Kernel memory optimization techniques
-
Book: 'Hands-On System Programming with Linux', Kaiwan N Billimoria, Packt. Prerequisites to this chapter (essential reading, really):
- Ch 1 : Linux System Architecture
- Ch 2 : Virtual Memory
-
Information regarding GFP flags internal usage, etc: 'Memory management when failure is not an option', LWN, Mar 2015
-
CPU Caches
- "How L1 and L2 CPU Caches Work, and Why They’re an Essential Part of Modern Chips", Joel Hruska, Aug 2018
- An example diagram of CPU (cache) hierarchy: "Memory hierarchy of an AMD Bulldozer server"
-
Slab layer - performance, etc
- 'Toward a more efficient slab allocator', LWN, Jon Corbet, Jan 2015
- Blog article 'INTERESTING NUMBERS'; see the section on Networking for some information on how the network subsystem has time critical code paths (and the resource links that follow)
-
"GNUPLOT 4.2 - A Brief Manual and Tutorial", Duke University
-
'Object-oriented design patterns in the kernel, part 1', Neil Brown, LWN, June 2011
-
'The "too small to fail" memory-allocation rule', Jon Corbet, LWN, Dec 2014
-
Blog article: 'linux slab poisoning 101', Mar 2009
-
Kernel memory debugging tools and techniques:
-
DMA - Direct Memory Access
- Books: 'Essential Linux Device Drivers', S Venkateswaran, and 'Linux Device Drivers', Rubini, Corbet & Hartman
- 'DMAEngine documentation', Linux kernel
- 'A deep dive into CMA', LWN, Mar 2012
- A quite simple and interesting example of a “DMA test application” device driver is from Xilinx (for it's Zynq PL330 DMA controller); wiki page here
- Q&A on SO: Linux DMA: Using the DMAengine for scatter-gather transactions, May 2016
-
OOM and VM Overcommit
- Toward more predictable and reliable out-of-memory handling, LWN, Jon Corbet, December 2015
- Quora: What are the disadvantages of disabling memory overcommit in Linux?
- Relevant Linux kernel documentation
- Blog article: 'Virtual memory settings in Linux - The Problem with Overcommit'
- RHEL specific but useful: 'Interpreting /proc/meminfo and free output for Red Hat Enterprise Linux 5, 6 and 7'
- Blog article: Surviving the Linux OOM Killer, October 2018
-
StackOverflow: How to mmap a Linux kernel buffer to userspace?
-
Detailed PDF: 'A complete guide to Linux process scheduling', Nikita Ishkov, Feb 2015
-
An excellent detailed code-level article on how very particularly the context switching code path switch_to() has evolved on the x86[_64] arch: 'Evolution of the x86 context switch in Linux', Maizure, Sept 2018
-
perf:
-
Linux kernel preemption and the latency-throughput tradeoff, Dec 2019
-
An excellent detailed code-level article on how, specifically, the context switching switch_to() code path has evolved on the x86[_64] arch: Evolution of the x86 context switch in Linux, Maizure, September 2018
-
Ftrace
-
Control Groups (cgroups)
- Good introductory article (focussed on cgroups1): 'Control Groups in Linux', Feb 2017
- 'Understanding the new control groups API', Rami Rosen, LWN, Mar 2016
- 'Control Group v2' : Linux kernel 'official' documentation
- man page (informational): 'cgroups - Linux control groups' (man 7 cgroups)
- RedHat System Design Guide (RHEL 8); focus on cgroups v1: 'SETTING LIMITS FOR APPLICATIONS'
- FB: Includes an interesting case study on how Facebook uses Linux's cgroups2 to perform equitable resource distribution on (some of) it's servers: 'Maximizing Resource Utilization with cgroup2'
- Blog article, examples of using cgroups v1 for CPU and memory bandwidth control: 'Linux Virtualization : Resource throttling using cgroups'
-
Hard Real-Time and Linux as an RTOS
- 'Inside Real-Time Linux', Feb 2017
- 'The Road to Real Time Linux', Steven Rostedt, Mar 2017
- VDC Survey on real-time response : The Embedded Muse, 341, 03 Jan 2018, Jack Ganssle
- Blog article: 'Algorithm time complexity and big O notation'
- Book: Automate This: How Algorithms Came to Rule Our World, Christopher Steiner
- Older wiki site on preempt_rt; it's in the process of being migrated to the new documentation for RTL; it still has very useful HOWTO guides, articles, etc: 'Real-Time Linux Wiki'
-
RTL – Real-Time Linux, using Linux as an RTOS:
- The RTL Collaborative Project
- RTL Real-Time documentation
- HOWTO: RTOS and RT Applications
- Interesting: "... compares the load results of the Ubuntu 18.04 LTS generic kernel 4.15.0-22-generic, the Ubuntu low-latency kernel 4.15.0-22-lowlatency and an Ubuntu Linux kernel patched to be fully preemptive 4.16.0-rt4-PREEMPT_RT_FULL as well as preemptive with low-latency 4.16.12-rt4+REEMPT_LL" : 'Low latency and real-time kernels for telco and NFV', Ubuntu, Oct 2018
- 'Real-time Linux communications - An evaluation of the Linux communication stack for real-time robotic applications', Sept 2018
- 'The real-time linux kernel: A survey on Preempt_RT', Feb 2019
- Detailed slides on cyclictest, good for understanding latency and it's measurement: 'Using and Understanding the Real-Time Cyclictest Benchmark', Rowand, Oct 2013
- 'Intro to Real-Time Linux for Embedded Developers', an interview with Steven Rostedt
-
[e]BPF tools for measuring scheduler / runqueue latencies (plus other stuff):
-
The still amazing and very relevant book on software engineering: 'The Mythical Man Month: Essays on Software Engineering', Frederick P Brooks, 1975, 1995
-
An excellent read: 'What every systems programmer should know about concurrency', M Kline, May 2018
-
Chip Overclock blog: Peeking under the Hood, Sloan, May 2012
-
Measuring context switching and memory overheads for Linux threads, Eli Bendersky, Sept 2018
-
Compiler Explorer website, Matt Godbolt; very useful: See the live disassembly of your code on a large choice of compilers and compiler flags
-
This presentation covers deadlock scenarios: 'Lockdep: how to read it's cryptic output', Steve Rostedt, Linux Plumbers Conf 2011
-
'Mutexes and Semaphores Demystified', Micheal Barr, May 2016
-
The Mars Pathfinder mission and Priority Inversion
- 'What really happened on Mars ?' Glenn Reeves
- A must-read (PDF): What the Media Couldn't Tell You About Mars Pathfinder
- Detailed paper (PDF): Mars Pathfinder: Priority Inversion Problem, R.M. Pathan
- More recently (May 2015), with respect to the NASA Curiosity Rover: 13 engineering truths proved by NASA's Curiosity Rover, EDN
-
OSFY magazine: 'How to Avoid Priority Inversion and Enable Priority Inheritance in Linux Kernel Programming', Thangaraju & Warade, Apr 2019
-
Spinlock internal implementation
-
Deeper details on the LKMM: Explanation of the Linux-Kernel Memory Model
-
Reference Counting API: kernsec: a summary
-
An extremely detailed take on concurrency topics, both hardware and software-wise: Is Parallel Programming Hard, And, If So, What Can You Do About It?, Paul E.McKenney, December 2019
-
False Sharing
-
Per-CPU variables:
-
Lock-free (or lockless) programming:
- What every systems programmer should know about concurrency, Matt Kline, May 2018
- Excellent "lock-free 101" articles:
- Good article series: 'Introduction to Lock-free Algorithms'
-
kdump and crash:
- Kernel documentation for kdump: The kexec-based Crash Dumping Solution
- Oops! Debugging Kernel Panics, Linux Journal, August 2019
- Excellent resource for learning and using the crash app: White paper: Red Hat Crash Utility, David Anderson
- Analyzing Linux kernel crash dumps with crash - The one tutorial that has it all, Dedoimedo, June 2010
-
Memory barriers:
-
Lockdep - 'Runtime locking correctness validator', kernel documentation - 'The kernel lock validator', LWN, J Corbet, May 2006 - 'Lockdep: how to read it's cryptic output', Steve Rostedt, Linux Plumbers Conf 2011 - 'LOCKDEP, AN INSIDE OUT PERSPECTIVE', Nahim El Atmani, Nov 2016 - (until it gets merged :-) : '[PATCH 16/28] locking/lockdep: Add explanation to lock usage rules in lockdep design doc', Yuyang Du, Apr 2019
-
RCU in the Linux kernel
- The excellent and extensive kernel community documentation: RCU
- My First Kernel Module: A Debugging Nightmare, Ryan Eberhardt. Nov 2020; see the section entitled 'RCU: Read, Copy, Update', excellent and clear!
- 'RCU Usage In the Linux Kernel: One Decade Later', McKenny et al (PDF), circa 2013
- A 3 series article to learn RCU: 'What is RCU, Fundamentally?', LWN, Paul McKenney, Dec 2007, Part 1 of 3
- 'Make any algorithm lock-free with this one crazy trick', May 2016
- 'The lockless page cache', LWN, Jon Corbet, July 2008 (an interesting article)
[End Doc]