GPU drivers must solve two fundamental problems: managing GPU-accessible memory and submitting commands to the GPU for execution. Whether rendering a frame or executing a model inference, the process begins with allocating, placing, and mapping memory for buffer objects (BOs), followed by submitting commands that reference these BOs and coordinating access from the CPU, GPU, and other devices.
In the Linux kernel, the DRM subsystem assumes these responsibilities: GEM and TTM manage BOs and their backing stores, dma-buf and dma-fence handle sharing and synchronization, while the GPU scheduler and drm_gpuvm manage command scheduling and GPU address spaces. These frameworks provide a unified abstraction for GPU drivers such as Intel, AMD, NVIDIA, and Arm Mali, while managing system memory, VRAM, and hardware queues below. This series traces the life cycle of buffer objects as its organizing principle, systematically analyzing this architecture.
The scope and organization of this series are described in The Main Thread and Organization of This Book, with the rationale for selecting this content found in The Evolution of DRM.
This series uses Linux 7.1 as its code baseline and covers modern GPU memory management and command submission mechanisms, addressing both graphics and AI compute workloads. It encompasses buffer sharing and implicit synchronization required by graphics stacks, as well as long-running jobs, user-space queues, and shared virtual memory that compute workloads depend on.
The series emphasizes explaining why each mechanism is designed as it is: first establishing the problem a mechanism solves and its hardware background, then analyzing design tradeoffs and kernel implementation, and finally validating these with code from drivers such as amdgpu, Xe, and panthor.
The content of this series is drawn from hands-on experience in GPU driver development. Problems such as VRAM leaks, eviction thrashing, synchronization deadlocks, and submission timeouts often require tracing through the intersection of GEM, TTM, dma-fence, and the scheduler to find the root cause. Related knowledge is scattered across kernel source code, mailing lists, and driver implementations, almost entirely in English. Existing Chinese materials are mostly fragmented discussions of individual interfaces or specific drivers; systematic explanations of these mechanisms are rare. This series aims to fill that gap: rather than introducing a single interface or driver in isolation, it follows the BO life cycle and connects object management, backing stores, sharing and synchronization, scheduling, address spaces, and command submission—explaining why each mechanism exists, how they work together, and providing developers who encounter similar problems with a coherent thread to follow.
Below is the series table of contents, which we recommend reading in order.
Chapter 1 DRM Subsystem Overview
- 1.1 Composition and Positioning of DRM
- 1.2 Evolution of DRM
- 1.3 Hardware Model of GPU Memory Access
- 1.4 Hardware Model of Command Submission
- 1.5 Main Thread and Organization of This Book
- 1.6 Chapter Summary
Chapter 2 DRM Framework
- 2.1 File Model of the DRM Framework
- 2.2 Driver Description Object drm_driver
- 2.3 Device Instance drm_device
- 2.4 Client Context drm_file
- 2.5 Framework ioctl and Access Control
- 2.6 DRM Device Driver Integration
- 2.7 Chapter Summary
Chapter 3 GEM Object Model
- 3.1 Requirements, Constraints, and Responsibility Boundaries of GEM
- 3.2 GEM Object Model
- 3.3 CPU View
- 3.4 GPU View
- 3.5 Inter-Device Views and Synchronization
- 3.6 GEM Object Driver Integration
- 3.7 Chapter Summary
Chapter 4 Lightweight Backing Store
- 4.1 Positioning of Lightweight Backing Store
- 4.2 Contiguous Memory Backing: drm_gem_dma_object
- 4.3 shmem File Backing Store
- 4.4 Structure and Creation of shmem Objects
- 4.5 Page Fetching, Referencing, and Object State
- 4.6 CPU Access and Page Fault Handling
- 4.7 Same-Device DMA and PRIME Sharing
- 4.8 Swapping Out and Purge
- 4.9 shmem Helper Driver Integration
- 4.10 Chapter Summary
Chapter 5 TTM Backing Store
- 5.1 Design Motivation and Responsibility Boundaries of TTM
- 5.2 Core Objects of TTM and TTM BO Life Cycle
- 5.3 ttm_device and Global State
- 5.4 ttm_buffer_object
- 5.5 Resources and Resource Managers
- 5.6 System Memory Domain
- 5.7 GTT Domain and GART Address Space
- 5.8 VRAM Domain
- 5.9 CPU Access to All Domains
- 5.10 Placement Policies and ttm_bo_validate
- 5.11 Migration Execution
- 5.12 Eviction
- 5.13 Swapping Out and Shrinker
- 5.14 TTM Driver Integration
- 5.15 Chapter Summary
Chapter 6 BO Sharing
- 6.1 Challenges of BO Sharing and dma-buf Solutions
- 6.2 dma-buf Mechanism
- 6.3 dma-buf Exporter
- 6.4 dma-buf Importer
- 6.5 Dynamic dma-buf
- 6.6 CPU Access and User-Space Synchronization — In review
- 6.7 PRIME Mechanism
- 6.8 dma-buf Heaps and udmabuf
- 6.9 BO Sharing Driver Integration
- 6.10 Chapter Summary
Chapter 7 Synchronization of Asynchronous Access
- 7.1 Synchronization Problems and Framework for Asynchronous Access
- 7.2 dma_fence Structure, Signal, and Wait
- 7.3 Fence Composition: array, chain, and unwrap
- 7.4 Implicit Synchronization on BOs: dma_resv
- 7.5 Fence Reification: sync_file
- 7.6 Synchronization Objects and Timelines: drm_syncobj
- 7.7 Multi-BO Locking: ww_mutex and drm_exec
- 7.8 Synchronization Mechanism Driver Integration
- 7.9 Chapter Summary
Chapter 8 GPU Scheduler Framework
- 8.1 Evolution of Command Submission — In review
- 8.2 Scheduling Requirements and Scheduler Positioning
- 8.3 Scheduler Instance drm_gpu_scheduler
- 8.4 Scheduling Entities and Jobs
- 8.5 Scheduling Loop and Flow Control
- 8.6 Timeout Detection and Recovery
- 8.7 Chapter Summary — In review
Chapter 9 Evolution of GPU Address Space
- 9.1 Evolution and Responsibility Division of GPU Virtual Address Space
- 9.2 Comparing GPU Memory Management with CPU MM
- 9.3 GPUVM Object Model
- 9.4 VA Space Changes and Operation Sequences
- 9.5 Shared resv, External Objects, and Re-validation
- 9.6 Page Table Updates and TLB Invalidation
- 9.7 Asynchronous VM_BIND and Binding Jobs
- 9.8 GPUVM Driver Integration
- 9.9 Chapter Summary
Chapter 10 Evolution of Submission Paths
- 10.1 Four Forms of Submission Paths
- 10.2 BO List-Based Submission — In review
- 10.3 VM-Based Submission — In review
- 10.4 Firmware Scheduling and Scheduler Assumptions — In review
- 10.5 dma_fence Constraints and Long-Running Jobs — In review
- 10.6 User-Space Queues — In review
- 10.7 Submission Path Driver Integration — In review
- 10.8 Chapter Summary — In review
Chapter 11 Shared Virtual Memory (SVM)
- 11.1 Requirements of SVM and DRM’s Two-Layer Framework
- 11.2 Kernel Foundations of Mirroring: mmu_interval_notifier and hmm_range_fault — In review
- 11.3 Kernel Foundations of Device Memory: ZONE_DEVICE and migrate_vma
- 11.4 drm_gpusvm Object Model: notifier and range — In review
- 11.5 Page Fetching and DMA Mapping — In review
- 11.6 Invalidation and Partial Unmapping — In review
- 11.7 Device Memory Provider: drm_pagemap — In review
- 11.8 Owner Groups, P2P Access, and pagemap Caching — In review
- 11.9 Migration to Device Memory — In review
- 11.10 Migration Back to System Memory — In review
- 11.11 Page Fault and Invalidation Driver Integration — Being written
- 11.12 Device Memory and Migration Driver Integration — Being written
- 11.13 Chapter Summary — Being written
Appendix A DRM Kernel Debugging Techniques
Being written.
Appendix B Kernel Fundamental Mechanisms
- B.1 Principles and Implementation of Linux Process Control
- B.2 Kernel Wait Queues
- B.3 Workqueues and Their Application in KFD SVM
- B.4 IDR Mechanism
- B.5 RCU Mechanism
- B.6 Pre-allocation Pattern on Lock-Held Paths
- B.7 shmem and tmpfs — In review
- B.8 address_space and Reverse Mapping — Not yet published
- B.9 drm_mm Range Allocator — In review
- B.10 gpu_buddy Buddy Allocator — In review
- B.11 drm_vma_offset_manager and Pseudo-Offset Management — In review
- B.12 Evolution of GPU Addressing Model and gpuva Reverse Indexing — In review
- B.13 Implementation Paths of GEM Object Life Cycle — In review
- B.14 anon_inode Mechanism