This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
realtime:documentation:technical_details:start [2023/09/25 15:00] costa.shul local_lock kernel doc |
realtime:documentation:technical_details:start [2023/10/03 08:37] (current) costa.shul remove elixir |
||
---|---|---|---|
Line 4: | Line 4: | ||
Therefore different mechanisms are implemented. Those mechanisms are partially available in mainline Linux. | Therefore different mechanisms are implemented. Those mechanisms are partially available in mainline Linux. | ||
The PREEMPT_RT patch has been partially merged into the mainline Linux kernel, starting from version 5.15 ((Realtime preemption locking core merged [[https://lwn.net/Articles/867919/]])) | The PREEMPT_RT patch has been partially merged into the mainline Linux kernel, starting from version 5.15 ((Realtime preemption locking core merged [[https://lwn.net/Articles/867919/]])) | ||
- | and activated with paramether | + | and enabled with ''CONFIG_PREEMPT_RT'' |
- | [[https://elixir.bootlin.com/linux/latest/A/ident/CONFIG_PREEMPT_RT|CONFIG_PREEMPT_RT]] | + | |
---- | ---- | ||
Line 35: | Line 34: | ||
[[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/mutex.h|Mutexes]] are implemented with | [[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/mutex.h|Mutexes]] are implemented with | ||
- | [[https://elixir.bootlin.com/linux/latest/A/ident/rt_mutex_base|rt mutexes]]. A rt_mutex implements [[https://elixir.bootlin.com/linux/latest/A/ident/rt_mutex_adjust_prio_chain|priority inheritance]] to avoid priority inversion. This also applies to sleeping spinlocks and rwlocks. However, the holder of a semaphore can be preempted but does not participate in priority inheritance. | + | [[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/rtmutex.h|rt mutexes]]. A rt_mutex implements priority inheritance (see ''rt_mutex_adjust_prio_chain'') to avoid priority inversion. This also applies to sleeping spinlocks and rwlocks. However, the holder of a semaphore can be preempted but does not participate in priority inheritance. |
<WRAP rightalign>[[https://docs.kernel.org/locking/rt-mutex-design.html|Read more about rt_mutex]]</WRAP> | <WRAP rightalign>[[https://docs.kernel.org/locking/rt-mutex-design.html|Read more about rt_mutex]]</WRAP> | ||
Line 41: | Line 40: | ||
===== Sleeping spinlocks ===== | ===== Sleeping spinlocks ===== | ||
- | In a non-PREEMPT-RT preemption model [[https://elixir.bootlin.com/linux/latest/A/ident/spinlock|spinlocks]] are mapped onto [[https://elixir.bootlin.com/linux/latest/A/ident/raw_spinlock|raw spinlocks]]. A task waiting for a spinlock held by another task spins until the task holding the spinlock releases it. Preemption is disabled in raw spinlock context. In PREEMPT_RT spinlocks are mapped onto [[https://elixir.bootlin.com/linux/latest/A/ident/rt_mutex_base|rt_mutex_base]] - "sleeping spinlocks", and raw spinlocks retain their behavior. A task waiting for a sleeping spinlock goes to sleep and is woken up when the spinlock is released. In the sleeping spinlock context preemption is not disabled. | + | In a non-PREEMPT-RT preemption model [[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/spinlock_types.h|spinlocks]] |
+ | are mapped onto | ||
+ | [[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/spinlock_types_raw.h|raw spinlocks]]. | ||
+ | A task waiting for a spinlock held by another task spins until the task holding the spinlock releases it. Preemption is disabled in raw spinlock context. In PREEMPT_RT spinlocks are mapped onto [[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/rtmutex.h|rt_mutex_base]] | ||
+ | and became "sleeping spinlocks", and raw spinlocks retain their behavior. A task waiting for a sleeping spinlock goes to sleep and is woken up when the spinlock is released. In the sleeping spinlock context preemption is not disabled. | ||
<WRAP rightalign>[[realtime:documentation:technical_details:sleeping_spinlocks|Read more about sleeping spinlocks]]</WRAP> | <WRAP rightalign>[[realtime:documentation:technical_details:sleeping_spinlocks|Read more about sleeping spinlocks]]</WRAP> |