User Tools

Site Tools


realtime:documentation:technical_details:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
realtime:documentation:technical_details:start [2017/02/08 14:30]
anna-maria created; moved into own namespace
realtime:documentation:technical_details:start [2023/10/03 08:37] (current)
costa.shul remove elixir
Line 1: Line 1:
-====== Technical details of PREEMPT_RT patch ======+====== Technical details of the real-time preemption ​======
  
-The main aim of the PREEMPT_RT patch is to //minimize the amount of kernel code that is non-preemptible//​ ((Paul McKenney, A realtime preemption overview [[https://​lwn.net/​Articles/​146861/​]])). Therefore different mechanisms are implemented. Those mechanisms are partially available in mainline Linux.+The main aim of the real-time preemption ​is to //minimize the amount of kernel code that is non-preemptible//​ ((Paul McKenney, A realtime preemption overview [[https://​lwn.net/​Articles/​146861/​]])). ​ 
 +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/​]])) 
 +and enabled with ''​CONFIG_PREEMPT_RT''​
  
 ---- ----
Line 8: Line 11:
 ===== High resolution timers ===== ===== High resolution timers =====
  
-The high resolution timers allows precise timed scheduling and removes the dependency of timers on the periodic scheduler tick (jiffies). ​The "high resolution timer design notes" explain the implementation details for high resolution timer, they are part of the kernel documentation. ​  +The high resolution timers allows precise timed scheduling and removes the dependency of timers on the periodic scheduler tick (jiffies). ​
  
-Since 2.6.24-rc1 the high resolution timer patches are fully merged and so the project is in "​history mode"​. +<WRAP rightalign>​[[realtime:​documentation:​technical_details:​hr_timers|Read more about High Resolution Timers]]</​WRAP>​
-Historically the high resolution timer patch was also integrated in the realtime ​preemption patch.+
  
-<WRAP rightalign>​[[realtime:​documentation:​hr_timers|Read more about High Resolution Timers]]</​WRAP>​ +===== Threaded interrupt handler =====
-</​WRAP>​+
  
-<WRAP half column>​ +The PREEMPT_RT patch forces the mechanism of threaded interrupt handlers. Due to this all interrupt handlers run in a threaded context except they are marked with the IRQF_NO_THREAD flag. This mechanism can be forced also in Linux mainline kernel without PREEMPT_RT patch by the kernel command line option ''​threadirqs''​. But there is a small difference in the resulted behavior.
-===== Sleeping spinlocks =====+
  
-In a non-PREEMPT-RT preemption model spinlocks are mapped onto 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 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:​threadirq|Read more about threaded interrupt handlers]]</​WRAP>​
  
-<WRAP rightalign>​[[realtime:​documentation:​sleeping_spinlocks|Read more about sleeping spinlocks]]</​WRAP>​+===== RCU =====
  
-</​WRAP>​+RCU mechanisms in mainline Linux are only preemptible if CONFIG_PREEMPT is set (Preemption model: "​Low-Latency Desktop"​). The PREEMPT_RT preemption models both use preemptible RCU mechanisms. Additionally the PREEMPT_RT patch eliminates RCU handling from all intermediate states and processes it only in its own thread.
  
-<​WRAP ​half column> +<​WRAP ​rightalign>​[[realtime:​documentation:​technical_details:​rcu|Read more about RCU]]</​WRAP>
-===== Threaded interrupt handler ===== +
- +
-The PREEMPT_RT patch forces the mechanism of threaded interrupt handlers. Due to this all interrupt handlers run in a threaded context except they are marked with the IRQF_NO_THREAD flag. This mechanism can be forced also in Linux mainline kernel without PREEMPT_RT patch by the kernel command line option ''​threadirqs''​. But there is a small difference in the resulted behavior.+
  
-<WRAP rightalign>​[[realtime:​documentation:​threadirq|Read more about threaded interrupt handlers]]</​WRAP>​ 
 </​WRAP>​ </​WRAP>​
  
 <WRAP half column> <WRAP half column>
 +
 ===== rt_mutex ===== ===== rt_mutex =====
  
-All mutexes in the mainline Linux kernel are replaced by rt_mutexes. A rt_mutex implements 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/​mutex.h|Mutexes]] ​are implemented with 
 +[[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>​[[realtime:documentation:​rt_mutex|Read more about rt_mutex]]</​WRAP>​ +<WRAP rightalign>​[[https://​docs.kernel.org/​locking/​rt-mutex-design.html|Read more about rt_mutex]]</​WRAP>​
-</​WRAP>​+
  
-<WRAP half column>​ +===== Sleeping spinlocks ​=====
-===== RCU =====+
  
-RCU mechanisms in mainline Linux are only preemptible if CONFIG_PREEMPT is set (Preemption ​model: "Low-Latency Desktop")The PREEMPT_RT preemption models both use preemptible RCU mechanismsAdditionally ​the PREEMPT_RT patch eliminates RCU handling from all intermediate states and processes it only in its own thread.+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 behaviorA task waiting for a sleeping spinlock goes to sleep and is woken up when the spinlock is releasedIn the sleeping spinlock context preemption is not disabled.
  
-<WRAP rightalign>​[[realtime:​documentation:​rcu|Read more about RCU]]</​WRAP>​+<WRAP rightalign>​[[realtime:​documentation:​technical_details:​sleeping_spinlocks|Read more about sleeping spinlocks]]</​WRAP>​ 
 + 
 +===== local_lock ===== 
 + 
 +local_lock maps to a per CPU spinlock, which protects the critical section while staying preemptible. See [[https://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​stable/​linux.git/​tree/​include/​linux/​local_lock_internal.h#​n104|local_lock_internal.h]] 
 + 
 +<WRAP rightalign>​[[https://​docs.kernel.org/​locking/​locktypes.html#​local-lock-and-preempt-rt|Read more about local_lock and PREEMPT_RT]]</​WRAP>​
  
 </​WRAP>​ </​WRAP>​
 +
realtime/documentation/technical_details/start.1486564257.txt.gz · Last modified: 2017/02/08 14:30 by anna-maria