Linux kernel locking documentation. PREEMPT_RT caveats section question
0
votes
0
answers
48
views
In the start of this section we see next mentions:
> local_lock on RT
>
> The mapping of local_lock to spinlock_t on PREEMPT_RT kernels has a
> few implications. For example, on a non-PREEMPT_RT kernel the
> following code sequence works as expected:
>
> local_lock_irq(&local_lock);
> raw_spin_lock(&lock);
>
> and is fully equivalent to:
>
> raw_spin_lock_irq(&lock);
>
> On a PREEMPT_RT kernel this code sequence breaks because
> local_lock_irq() is mapped to a per-CPU spinlock_t which neither
> disables interrupts nor preemption.
It is okay. First code example try lock irqs and hold raw spin lock and on non-PREEMPT_RT kernel it is equals to second section code. But, after last code the mention about PREEMPT_RT kernels says that
local_lock_irq()
does not work on PREEMPT_RT kernels, so on these kernels we cant use first code example instead second. So the continue of documentation should say something like next thing: "On PREEMPT_RT kernel you should use second code example strictly". BUT, documentation says next thing:
> The following code sequence works perfectly correct on both PREEMPT_RT
> and non-PREEMPT_RT kernels:
>
> local_lock_irq(&local_lock); spin_lock(&lock);
What? On PREEMPT_RT kernel: typedef spinlock_t local_lock_t
, and local_lock_irq
mapped to __local_lock
which does next things: disables migration and calls spin_lock
with lock variable pointer of this cpu. After that we call spin_lock
(again) with another lock variable. Why we should do this? I dont understand what does author want say me. Thanks.
**UPD:**
If no answer, then I will try. If lock and raw_lock same on non-PREEMPT_RT kernel then I think autor want to say that dont need use raw on PREEMPT_RT as it is extra whole locking for them, just use simple lock instead and all works as need in most cases. lock irq will disables migrate and holds this cpu lock variable, then spin_lock for general lock and we get ordered flow of execution. Correct me if I'm wrong.
Asked by nx4n
(111 rep)
Nov 10, 2024, 12:16 PM
Last activity: Nov 12, 2024, 04:59 AM
Last activity: Nov 12, 2024, 04:59 AM