0%

Book Description

Explore Implementation of core kernel subsystems

About This Book

  • Master the design, components, and structures of core kernel subsystems
  • Explore kernel programming interfaces and related algorithms under the hood
  • Completely updated material for the 4.12.10 kernel

Who This Book Is For

If you are a kernel programmer with a knowledge of kernel APIs and are looking to build a comprehensive understanding, and eager to explore the implementation, of kernel subsystems, this book is for you. It sets out to unravel the underlying details of kernel APIs and data structures, piercing through the complex kernel layers and gives you the edge you need to take your skills to the next level.

What You Will Learn

  • Comprehend processes and fles - the core abstraction mechanisms of the Linux kernel that promote effective simplification and dynamism
  • Decipher process scheduling and understand effective capacity utilization under general and real-time dispositions
  • Simplify and learn more about process communication techniques through signals and IPC mechanisms
  • Capture the rudiments of memory by grasping the key concepts and principles of physical and virtual memory management
  • Take a sharp and precise look at all the key aspects of interrupt management and the clock subsystem
  • Understand concurrent execution on SMP platforms through kernel synchronization and locking techniques

In Detail

Mastering Linux Kernel Development looks at the Linux kernel, its internal arrangement and design, and various core subsystems, helping you to gain significant understanding of this open source marvel. You will look at how the Linux kernel, which possesses a kind of collective intelligence thanks to its scores of contributors, remains so elegant owing to its great design.

This book also looks at all the key kernel code, core data structures, functions, and macros, giving you a comprehensive foundation of the implementation details of the kernel's core services and mechanisms. You will also look at the Linux kernel as well-designed software, which gives us insights into software design in general that are easily scalable yet fundamentally strong and safe.

By the end of this book, you will have considerable understanding of and appreciation for the Linux kernel.

Style and approach

Each chapter begins with the basic conceptual know-how for a subsystem and extends into the details of its implementation. We use appropriate code excerpts of critical routines and data structures for subsystems.

Table of Contents

  1. Title Page
  2. Copyright
    1. Mastering Linux Kernel Development
  3. Credits
  4. About the Author
  5. About the Reviewer
  6. www.PacktPub.com
    1. Why subscribe?
  7. Customer Feedback
  8. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Errata
      2. Piracy
      3. Questions
  9. Comprehending Processes, Address Space, and Threads
    1. Processes
      1. The illusion called address space
      2. Kernel and user space
        1. Process context
    2. Process descriptors
      1. Process attributes - key elements
        1. state
        2. pid
        3. tgid
        4. thread info
        5. flags
        6. exit_code and exit_signal
        7. comm
        8. ptrace
      2. Process relations - key elements
        1. real_parent and parent
        2. children
        3. sibling
        4. group_leader
      3. Scheduling attributes - key elements
        1. prio and static_prio
        2. se, rt, and dl
        3. policy
        4. cpus_allowed
        5. rt_priority
      4. Process limits - key elements
      5. File descriptor table - key elements
        1. fs
        2. files
      6. Signal descriptor - key elements
        1. signal
        2. sighand
        3. sigset_t blocked, real_blocked
        4. pending
        5. sas_ss_sp
        6. sas_ss_size
    3. Kernel stack
    4. The issue of stack overflow
    5. Process creation
      1. fork()
      2. Copy-on-write (COW)
      3. exec
      4. vfork()
      5. Linux support for threads
        1. clone()
    6. Kernel threads
      1. do_fork() and copy_process()
    7. Process status and termination
      1. wait
      2. exit
    8. Namespaces and cgroups
      1. Mount namespaces
      2. UTS namespaces
      3. IPC namespaces
      4. PID namespaces
      5. Network namespaces
      6. User namespaces
      7. Cgroup namespaces
      8. Control groups (cgroups)
    9. Summary
  10. Deciphering the Process Scheduler
    1. Process schedulers
    2. Linux process scheduler design
    3. Runqueue
    4. The scheduler's entry point
    5. Process priorities
    6. Scheduler classes
    7. Completely Fair Scheduling class (CFS)
      1. Computing priorities and time slices under CFS
      2. CFS's runqueue
      3. Group scheduling
      4. Scheduling entities under many-core systems
      5. Scheduling policies
    8. Real-time scheduling class
      1. FIFO
      2. RR
      3. Real-time group scheduling
      4. Deadline scheduling class (sporadic task model deadline scheduling)
    9. Scheduler related system calls
      1. Processor affinity calls
    10. Process preemption
    11. Summary
  11. Signal Management
    1. Signals
    2. Signal-management APIs
      1. Raising signals from a program
      2. Waiting for queued signals
    3. Signal data structures
      1. Signal descriptors
      2. Blocked and pending queues
      3. Signal handler descriptor
    4. Signal generation and delivery
      1. Signal-generation calls
      2. Signal delivery
      3. Executing user-mode handlers
      4. Setting up user-mode handler frames
    5. Restarting interrupted system calls
    6. Summary
  12. Memory Management and Allocators
    1. Initialization operations
      1. Page descriptor
        1. Flags
        2. Mapping
    2. Zones and nodes
      1. Memory zones
      2. Memory nodes
        1. Node descriptor structure
        2. Zone descriptor structure
    3. Memory allocators
      1. Page frame allocator
        1. Buddy system
      2. GFP mask
        1. Zone modifiers
        2. Page mobility and placement
        3. Watermark modifiers
        4. Page reclaim modifiers
        5. Action modifiers
        6. Type flags
      3. Slab allocator
        1. Kmalloc caches
        2. Object caches
        3. Cache management
        4. Cache layout - generic
        5. Slub data structures
      4. Vmalloc
      5. Contiguous Memory Allocator (CMA)
    4. Summary
  13. Filesystems and File I/O
    1. Filesystem - high-level view
      1. Metadata
        1. Inode (index node)
        2. Data block map
        3. Directories
        4. Superblock
      2. Operations
        1. Mount and unmount operations
        2. File creation and deletion operations
        3. File open and close operations
        4. File read and write operations
      3. Additional features
        1. Extended file attributes
        2. Filesystem consistency and crash recovery
        3. Access control lists (ACLs)
    2. Filesystems in the Linux kernel
      1. Ext family filesystems
        1. Ext2
        2. Ext3
        3. Ext4
    3. Common filesystem interface
      1. VFS structures and operations
        1. struct superblock
        2. struct inode
        3. Struct dentry
        4. struct file
    4. Special filesystems
      1. Procfs
      2. Sysfs
      3. Debugfs
    5. Summary
  14. Interprocess Communication
    1. Pipes and FIFOs
      1. pipefs
    2. Message queues
      1. System V message queues
        1. Data structures
      2. POSIX message queues
    3. Shared memory
      1. System V shared memory
        1. Operation interfaces
          1. Allocating shared memory
          2. Attaching a shared memory
          3. Detaching shared memory
        2. Data structures
      2. POSIX shared memory
    4. Semaphores
      1. System V semaphores
        1. Data structures
      2. POSIX semaphores
    5. Summary
  15. Virtual Memory Management
    1. Process address space
      1. Process memory descriptor
        1. Managing virtual memory areas
          1. Locating a VMA
          2. Merging VMA regions
        2. struct address_space
      2. Page tables
    2. Summary
  16. Kernel Synchronization and Locking
    1. Atomic operations
      1. Atomic integer operations
      2. Atomic bitwise operations
    2. Introducing exclusion locks
      1. Spinlocks
        1. Alternate spinlock APIs
        2. Reader-writer spinlocks
      2. Mutex locks
        1. Debug checks and validations
        2. Wait/wound mutexes
          1. Operation interfaces:
      3. Semaphores
        1. Reader-writer semaphores
      4. Sequence locks
        1. API
      5. Completion locks
        1. Initialization
        2. Waiting for completion
        3. Signalling completion
    3. Summary
  17. Interrupts and Deferred Work
    1. Interrupt signals and vectors
    2. Programmable interrupt controller
      1. Interrupt controller operations
      2. IRQ descriptor table
    3. High-level interrupt-management interfaces
      1. Registering an interrupt handler
      2. Deregistering an interrupt handler
      3. Threaded interrupt handlers
      4. Control interfaces
      5. IRQ stacks
    4. Deferred work
      1. Softirqs
      2. Tasklets
      3. Workqueues
        1. Interface API
        2. Creating dedicated workqueues
    5. Summary
  18. Clock and Time Management
    1. Time representation
      1. Timing hardware
        1. Real-time clock (RTC)
        2. Timestamp counter (TSC)
        3. Programmable interrupt timer (PIT)
        4. CPU local timer
        5. High-precision event timer (HPET)
        6. ACPI power management timer (ACPI PMT)
    2. Hardware abstraction
      1. Calculating elapsed time
    3. Linux timekeeping data structures, macros, and helper routines
      1. Jiffies
      2. Timeval and timespec
      3. Tracking and maintaining time
      4. Tick and interrupt handling
      5. Tick devices
    4. Software timers and delay functions
      1. Dynamic timers
      2. Race conditions with dynamic timers
      3. Dynamic timer handling
      4. Delay functions
    5. POSIX clocks
    6. Summary
  19. Module Management
    1. Kernel modules
      1. Elements of an LKM
        1. Binary layout of a LKM
      2. Load and unload operations
        1. Module data structures
          1. Memory layout
    2. Summary
3.145.93.221