| From: |
| Sebastian Andrzej Siewior <bigeasy-AT-linutronix.de> |
| To: |
| linux-kernel-AT-vger.kernel.org |
| Subject: |
| [PATCH 0/8] Introduce local_lock() |
| Date: |
| Tue, 19 May 2020 22:19:04 +0200 |
| Message-ID: |
| <20200519201912.1564477-1-bigeasy@linutronix.de> |
| Cc: |
| Peter Zijlstra <peterz-AT-infradead.org>, Ingo Molnar <mingo-AT-kernel.org>, Steven Rostedt <rostedt-AT-goodmis.org>, Will Deacon <will-AT-kernel.org>, Thomas Gleixner <tglx-AT-linutronix.de>, "Paul E . McKenney" <paulmck-AT-kernel.org>, Linus Torvalds <torvalds-AT-linux-foundation.org> |
| Archive-link: |
| Article |
preempt_disable() and local_irq_disable/save() are in principle per CPU big
kernel locks. This has several downsides:
- The protection scope is unknown
- Violation of protection rules is hard to detect by instrumentation
- For PREEMPT_RT such sections, unless in low level critical code, can
violate the preemptability constraints.
To address this PREEMPT_RT introduced the concept of local_locks which are
strictly per CPU.
The lock operations map to preempt_disable(), local_irq_disable/save() and
the enabling counterparts on non RT enabled kernels.
If lockdep is enabled local locks gain a lock map which tracks the usage
context. This will catch cases where an area is protected by
preempt_disable() but the access also happens from interrupt context. local
locks have identified quite a few such issues over the years, the most
recent example is:
b7d5dc21072cd ("random: add a spinlock_t to struct batched_entropy")
Aside of the lockdep coverage this also improves code readability as it
precisely annotates the protection scope.
PREEMPT_RT substitutes these local locks with 'sleeping' spinlocks to
protect such sections while maintaining preemtability and CPU locality.
The following series introduces the infrastructure including
documentation and provides a couple of examples how they are used to
adjust code to be RT ready.
Sebastian