Unreliable Guide To Locking

Rusty Russell

      
     


Table of Contents
Introduction
The Problem With Concurrency
Race Conditions and Critical Regions
Locking in the Linux Kernel
Two Main Types of Kernel Locks: Spinlocks and Semaphores
Locks and Uniprocessor Kernels
Locking Only In User Context
Locking Between User Context and Softirqs
Locking Between User Context and Tasklets
Locking Between User Context and Timers
Locking Between Tasklets/Timers
The Same Tasklet/Timer
Different Tasklets/Timers
Locking Between Softirqs
The Same Softirq
Different Softirqs
Hard IRQ Context
Locking Between Hard IRQ and Softirqs/Tasklets
Locking Between Two Hard IRQ Handlers
Cheat Sheet For Locking
Table of Minimum Requirements
Common Examples
All In User Context
Accessing From Interrupt Context
Exposing Objects Outside This File
Using Atomic Operations For The Reference Count
Protecting The Objects Themselves
Common Problems
Deadlock: Simple and Advanced
Preventing Deadlock
Overzealous Prevention Of Deadlocks
Racing Timers: A Kernel Pastime
Locking Speed
Read/Write Lock Variants
Avoiding Locks: Read Copy Update
Per-CPU Data
Data Which Mostly Used By An IRQ Handler
What Functions Are Safe To Call From Interrupts?
Some Functions Which Sleep
Some Functions Which Don't Sleep
Further reading
Thanks
Glossary