Chapter 5. Cheat Sheet For Locking

Table of Contents

Table of Minimum Requirements

Pete Zaitcev gives the following summary:

Table of Minimum Requirements

The following table lists the minimum locking requirements between various contexts. In some cases, the same context can only be running on one CPU at a time, so no locking is required for that context (eg. a particular thread can only run on one CPU at a time, but if it needs shares data with another thread, locking is required).

Remember the advice above: you can always use spin_lock_irqsave(), which is a superset of all other spinlock primitives.

Table 5.1. Table of Locking Requirements

 IRQ Handler AIRQ Handler BSoftirq ASoftirq BTasklet ATasklet BTimer ATimer BUser Context AUser Context B
IRQ Handler ANone         
IRQ Handler BSLISNone        
Softirq ASLISLISL       
Softirq BSLISLISLSL      
Tasklet ASLISLISLSLNone     
Tasklet BSLISLISLSLSLNone    
Timer ASLISLISLSLSLSLNone   
Timer BSLISLISLSLSLSLSLNone  
User Context ASLISLISLBHSLBHSLBHSLBHSLBHSLBHNone 
User Context BSLISLISLBHSLBHSLBHSLBHSLBHSLBHMLINone

Table 5.2. Legend for Locking Requirements Table

SLISspin_lock_irqsave
SLIspin_lock_irq
SLspin_lock
SLBHspin_lock_bh
MLImutex_lock_interruptible