-
Notifications
You must be signed in to change notification settings - Fork 4
/
basic.txt
101 lines (78 loc) · 2.59 KB
/
basic.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
LINUX:
- flow of interrupt/vector allocation and process
- spinlock/mutex/rcu/barrier
XEN:
- xen and linux boot process
- difference between pvm/hvm/pvh
- pv spinlock
- pv timer
- how system call and exception work
- how pci/msic is initialized
- xen clocksource
- event channel (2l and fifo): evtchn/virq/pirq/ipi
- grant table
- pv driver, xenbus and xenstore
QUESTIONS:
- difference between irq and threaded irq
- sleep in workqueue/softirq/tasklet/thread?
- preemption in workqueue/softirq/tasklet/thread?
- vmalloc/kmalloc difference
- explain spinlock/mutex/rcu
- explain process creation and exit
- explain thread context switch?
- explain hung_task/rcu_stall/soft_lockup/hard_lockdup
slides:
- preemption
- spinlock, mutex, rcu/srcu
- scheduling while atomic
- hung_task/rcu_stall/soft_lockup/hard_lockdup
- lockdep
- kmemleak
- slub debug
- kasan
--------------------------------------------------------------------------
spin lock:
- cannot sleep because spin_lock expects preempt to be disabled. To sleep on
purpose might schedule another thread which might call the spin lock again.
spin_lock()
-> preempt_disable()
-> acquire spin lock
spin_lock_irq()
-> local_irq_disable()
-> preempt_disable()
-> acquire spin lock
spin_lock_irqsave()
-> local_irq_save()
-> arch_local_save_flags()
-> arch_local_irq_disable()
-> preempt_disable()
-> acquire spin lock
spin_lock_irq()
-> __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET)
disable both preemption (CONFIG_PREEMPT_COUNT) and softirqs
-> acquire spin lock
--------------------------------------------------------------------------
To schedule (e.g., sleep) in irq context would panic in the worst case because
there is no thread context for interrupt. The kernel is not able to recover the
previous context for interrupt back.
IRQ:
- software irq (used by request_threaded_irq()/request_irq()) is mapped to
hardware vector and the mapping is stored by vector_irq[] which is used
by do_IRQ().
- Threaded IRQ is to allow some thread (e.g., realtime) to have higher priority
than IRQ.
softirq:
- cannot sleep in irq/softirq/tasklet
- same softirq can run on multiple cpu simultaneously
tasklet:
- cannot sleep in irq/softirq/tasklet
- same tasklet can only run on one cpu simultaneously
workqueue:
- can sleep
--------------------------------------------------------------------------
preemption:
__schedule()
-> schedule_debug()
PREEMPT_DISABLE_OFFSET is the preempt_count offset after preempt_disable(). If
(preempt_count() != PREEMPT_DISABLE_OFFSET), schedule_debug() would warn "BUG:
scheduling while atomic:...".