Billimoria, Kaiwan N. | Linux Kernel Programming | E-Book | www.sack.de
E-Book

E-Book, Englisch, 826 Seiten

Billimoria, Kaiwan N. Linux Kernel Programming

A comprehensive and practical guide to kernel internals, writing modules, and kernel synchronization
2. Auflage 2024
ISBN: 978-1-80324-108-1
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection

A comprehensive and practical guide to kernel internals, writing modules, and kernel synchronization

E-Book, Englisch, 826 Seiten

ISBN: 978-1-80324-108-1
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection



The 2nd Edition of Linux Kernel Programming is an updated, comprehensive guide for those new to Linux kernel development. Built around the latest 6.1 Long-Term Support (LTS) Linux kernel, which is maintained until December 2026, this edition explores its key features and enhancements. Additionally, with the Civil Infrastructure Project extending support for the 6.1 Super LTS (SLTS) kernel until August 2033, this book will remain relevant for years to come.
You'll begin this exciting journey by learning how to build the kernel from source. Step by step, 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 (for example, 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 build a strong understanding of the fundamentals to writing the Linux kernel and kernel module code that can straight away be used in real-world projects and products.

Billimoria, Kaiwan N. Linux Kernel Programming jetzt bestellen!

Weitere Infos & Material


Table of Contents - Linux Kernel Programming – A Quick Introduction
- Building the 6.x Linux Kernel from Source - Part 1
- Building the 6.x Linux Kernel from Source - Part 2
- Writing Your First Kernel Module - Part 1
- Writing Your First Kernel Module - Part 2
- Kernel Internals Essentials - Processes and Threads
- Memory Management Internals - Essentials
- Kernel Memory Allocation for Module Authors - Part 1
- Kernel Memory Allocation for Module Authors - Part 2
- The CPU Scheduler - Part 1
- The CPU Scheduler - Part 2
- Kernel Synchronization - Part 1
- Kernel Synchronization - Part 2


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, . It’s an excellent industry-aligned beginner’s guide to writing 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!

Who this book is for


This book is primarily for those of you beginning your journey in the vast arena of learning and understanding modern Linux kernel architecture and internals, Linux kernel module development and, to some extent, Linux device driver development. It’s also very much targeted at those of you who have already been working on Linux modules and/or drivers, who wish to gain a much deeper, well-structured understanding of Linux kernel architecture, memory management, task scheduling, cgroups, and synchronization. This level of knowledge about the underlying OS, covered in a properly structured manner, will help you no end when you face difficult-to-debug real-world situations.

What’s been added in the second edition?


A pretty amount of new material has been added into this, the of the 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
  • ,
    • Introduction to the book
  • ,
    • The new LTS kernel lifetime mandate
    • More details on the kernel’s Kconfig+Kbuild system
    • Updated approaches on configuring the kernel
  • ,
    • More details on the () image
    • Cross-compiling the kernel on an x86_64 host to an AArch64 target
  • ,
    • new-ish indexing feature covered
    • Powerful kernel dynamic debug feature introduced
    • Rate-limiting macros updated (deprecated ones not used)
  • ,
    • A better, ‘better’ Makefile (v0.2)
  • ,
    • New linked list demo module
  • ,
    • New coverage on how address translation works (including diagrams)
  • ,
    • Coverage on using the “exact” page allocator API pair
    • FAQs regarding (slab) memory usage and their answers
    • The graphing demo (via ) is now automated and even saved to an image file, via a helper script
    • Finding internal fragmentation (wastage) within the kernel
  • ,
    • Extracting useful information regarding slab caches
    • A word on slab shrinkers
    • Better coverage on the OOM killer (and ) 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
  • ,
    • 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 is invoked
  • ,
    • 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 and manually to perform CPU bandwidth allocation
    • A note on Google’s ghOSt OS
  • ,
    • A new intro to the LKMM (Linux Kernel Memory Model)
    • More on locking plus deadlock avoidance guidelines
  • ,
    • Expanded coverage on CPU caching and cache effects
    • New coverage on the powerful lock-free RCU synchronization technology
  • ,
    • 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!

What this book covers


, , briefs you about the exciting journey in the sections of the book, which cover everything from building the Linux kernel from source to understanding and...


Billimoria Kaiwan N. :

Kaiwan N. Billimoria taught himself BASIC programming on his dad's IBM PC back in 1983. He was programming in C and Assembly on DOS until he discovered the joys of Unix, and by around 1997, Linux! Kaiwan has worked on many aspects of the Linux system programming stack, including Bash scripting, system programming in C, kernel internals, device drivers, and embedded Linux work. He has actively worked on several commercial/FOSS projects. His contributions include drivers to the mainline Linux OS and many smaller projects hosted on GitHub. His Linux passion feeds well into his passion for teaching these topics to engineers, which he has done for well over two decades now. He's also the author of Hands-On System Programming with Linux, Linux Kernel Programming (and its Part 2 book) and Linux Kernel Debugging. It doesn't hurt that he is a recreational ultrarunner too.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.