diff options
Diffstat (limited to 'schulung_tools/notes/kernel-locking.txt')
| -rw-r--r-- | schulung_tools/notes/kernel-locking.txt | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/schulung_tools/notes/kernel-locking.txt b/schulung_tools/notes/kernel-locking.txt new file mode 100644 index 0000000..1757227 --- /dev/null +++ b/schulung_tools/notes/kernel-locking.txt @@ -0,0 +1,50 @@ + ++ locking + Documentation/kernel-hacking/locking.rst + - atomic operations + Documentation/atomic_t.txt + atomic_t atomic64_t and atomic_long_t + atomic_read(), atomic_set() + atomic[_fetch]_{add,sub,inc,dec}() + atomic[_fetch]_{and,or,xor,andnot}() + .. + - mutex + waiter can sleep, not usable in tasklets/timer/irqs + - spinlock / rwlock + spin_lock # use if lock is shared in different tasklets / only in user context + spin_lock_bh / disables softirqs # use if lock is shared in user context and softirqs (tasklets/timer) + spin_lock_irqsave / disables irqs # use if lock is shared in user context and irq context + --> Use irqsave variant if you're unsure + --> Avoid holding spinlock for more than 5 lines of code and across any + function call (except accessors like :c:func:`readb()`). + +============== ============= ============= ========= ========= ========= ========= ======= ======= ============== ============== +. IRQ Handler A IRQ Handler B Softirq A Softirq B Tasklet A Tasklet B Timer A Timer B User Context A User Context B +============== ============= ============= ========= ========= ========= ========= ======= ======= ============== ============== +IRQ Handler A None +IRQ Handler B SLIS None +Softirq A SLI SLI SL +Softirq B SLI SLI SL SL +Tasklet A SLI SLI SL SL None +Tasklet B SLI SLI SL SL SL None +Timer A SLI SLI SL SL SL SL None +Timer B SLI SLI SL SL SL SL SL None +User Context A SLI SLI SLBH SLBH SLBH SLBH SLBH SLBH None +User Context B SLI SLI SLBH SLBH SLBH SLBH SLBH SLBH MLI None +============== ============= ============= ========= ========= ========= ========= ======= ======= ============== ============== + +Table: Table of Locking Requirements + ++--------+----------------------------+ +| SLIS | spin_lock_irqsave | ++--------+----------------------------+ +| SLI | spin_lock_irq | ++--------+----------------------------+ +| SL | spin_lock | ++--------+----------------------------+ +| SLBH | spin_lock_bh | ++--------+----------------------------+ +| MLI | mutex_lock_interruptible | ++--------+----------------------------+ + +Table: Legend for Locking Requirements Table + |
