|
XenevaOS
|
#include <linux/compiler.h>#include <linux/cleanup.h>#include <linux/kcsan-checks.h>#include <linux/lockdep.h>#include <linux/mutex.h>#include <linux/preempt.h>#include <linux/seqlock_types.h>#include <linux/spinlock.h>#include <asm/processor.h>

Go to the source code of this file.
Classes | |
| struct | seqcount_latch_t |
| struct | ss_tmp |
Macros | |
| #define | KCSAN_SEQLOCK_REGION_MAX 1000 |
| #define | SEQCOUNT_DEP_MAP_INIT(lockname) |
| #define | seqcount_init(s) __seqcount_init(s, NULL, NULL) |
| #define | seqcount_lockdep_reader_access(x) |
| #define | class_seqlock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(seqlock_init, _T) |
| #define __read_seqcount_begin | ( | s | ) |
__read_seqcount_begin() - begin a seqcount_t read section @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Return: count to be passed to read_seqcount_retry()
| #define __read_seqcount_retry | ( | s, | |
| start | |||
| ) | do___read_seqcount_retry(seqprop_const_ptr(s), start) |
__read_seqcount_retry() - end a seqcount_t read section w/o barrier @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants @start: count, from read_seqcount_begin()
__read_seqcount_retry is like read_seqcount_retry, but has no smp_rmb() barrier. Callers should ensure that smp_rmb() or equivalent ordering is provided before actually loading any of the variables that are to be protected in this critical section.
Use carefully, only in critical code, and comment how the barrier is provided.
Return: true if a read section retry is required, else false
| #define __scoped_seqlock_read | ( | _seqlock, | |
| _target, | |||
| _s | |||
| ) |
| #define __SEQ_RT IS_ENABLED(CONFIG_PREEMPT_RT) |
| #define __SEQLOCK_UNLOCKED | ( | lockname | ) |
| #define __seqprop | ( | s, | |
| prop | |||
| ) |
| #define __seqprop_case | ( | s, | |
| lockname, | |||
| prop | |||
| ) | seqcount_##lockname##_t: __seqprop_##lockname##_##prop |
| #define class_seqlock_init_constructor | ( | _T | ) | WITH_LOCK_GUARD_1_ATTRS(seqlock_init, _T) |
| #define DEFINE_SEQLOCK | ( | sl | ) | seqlock_t sl = __SEQLOCK_UNLOCKED(sl) |
DEFINE_SEQLOCK(sl) - Define a statically allocated seqlock_t @sl: Name of the seqlock_t instance
| #define KCSAN_SEQLOCK_REGION_MAX 1000 |
| #define raw_read_seqcount | ( | s | ) |
raw_read_seqcount() - read the raw seqcount_t counter value @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
raw_read_seqcount opens a read critical section of the given seqcount_t, without any lockdep checking, and without checking or masking the sequence counter LSB. Calling code is responsible for handling that.
Return: count to be passed to read_seqcount_retry()
| #define raw_read_seqcount_begin | ( | s | ) | __read_seqcount_begin(s) |
raw_read_seqcount_begin() - begin a seqcount_t read section w/o lockdep @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Return: count to be passed to read_seqcount_retry()
| #define raw_seqcount_begin | ( | s | ) |
raw_seqcount_begin() - begin a seqcount_t read critical section w/o lockdep and w/o counter stabilization @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
raw_seqcount_begin opens a read critical section of the given seqcount_t. Unlike read_seqcount_begin(), this function will not wait for the count to stabilize. If a writer is active when it begins, it will fail the read_seqcount_retry() at the end of the read critical section instead of stabilizing at the beginning of it.
Use this only in special kernel hot paths where the read section is small and has a high probability of success through other external means. It will save a single branching instruction.
Return: count to be passed to read_seqcount_retry()
| #define raw_seqcount_try_begin | ( | s, | |
| start | |||
| ) |
raw_seqcount_try_begin() - begin a seqcount_t read critical section w/o lockdep and w/o counter stabilization @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants @start: count to be passed to read_seqcount_retry()
Similar to raw_seqcount_begin(), except it enables eliding the critical section entirely if odd, instead of doing the speculation knowing it will fail.
Useful when counter stabilization is more or less equivalent to taking the lock and there is a slowpath that does that.
If true, start will be set to the (even) sequence count read.
Return: true when a read critical section is started.
| #define raw_write_seqcount_barrier | ( | s | ) | do_raw_write_seqcount_barrier(seqprop_ptr(s)) |
raw_write_seqcount_barrier() - do a seqcount_t write barrier @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
This can be used to provide an ordering guarantee instead of the usual consistency guarantee. It is one wmb cheaper, because it can collapse the two back-to-back wmb()s.
Note that writes surrounding the barrier should be declared atomic (e.g. via WRITE_ONCE): a) to ensure the writes become visible to other threads atomically, avoiding compiler optimizations; b) to document which writes are meant to propagate to the reader critical section. This is necessary because neither writes before nor after the barrier are enclosed in a seq-writer critical section that would ensure readers are aware of ongoing writes::
seqcount_t seq; bool X = true, Y = false;
void read(void) { bool x, y;
do { int s = read_seqcount_begin(&seq);
x = X; y = Y;
} while (read_seqcount_retry(&seq, s));
BUG_ON(!x && !y); }
void write(void) { WRITE_ONCE(Y, true);
| #define raw_write_seqcount_begin | ( | s | ) |
raw_write_seqcount_begin() - start a seqcount_t write section w/o lockdep @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Context: check write_seqcount_begin()
| #define raw_write_seqcount_end | ( | s | ) |
raw_write_seqcount_end() - end a seqcount_t write section w/o lockdep @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Context: check write_seqcount_end()
| #define read_seqcount_begin | ( | s | ) |
read_seqcount_begin() - begin a seqcount_t read critical section @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Return: count to be passed to read_seqcount_retry()
| #define read_seqcount_retry | ( | s, | |
| start | |||
| ) | do_read_seqcount_retry(seqprop_const_ptr(s), start) |
read_seqcount_retry() - end a seqcount_t read critical section @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants @start: count, from read_seqcount_begin()
read_seqcount_retry closes the read critical section of given seqcount_t. If the critical section was invalid, it must be ignored (and typically retried).
Return: true if a read section retry is required, else false
| #define read_seqlock_excl_irqsave | ( | lock, | |
| flags | |||
| ) | do { flags = __read_seqlock_excl_irqsave(lock); } while (0) |
read_seqlock_excl_irqsave() - start a non-interruptible seqlock_t locking reader section @lock: Pointer to seqlock_t @flags: Stack-allocated storage for saving caller's local interrupt state, to be passed to read_sequnlock_excl_irqrestore().
_irqsave variant of read_seqlock_excl(). Use this only if the seqlock_t write side section, or other read sections, can be invoked from a hardirq context.
| #define scoped_seqlock_read | ( | _seqlock, | |
| _target | |||
| ) | __scoped_seqlock_read(_seqlock, _target, __UNIQUE_ID(seqlock)) |
scoped_seqlock_read() - execute the read-side critical section without manual sequence counter handling or calls to other helpers @_seqlock: pointer to seqlock_t protecting the data @_target: an enum ss_state: one of {ss_lock, ss_lock_irqsave, ss_lockless} indicating the type of critical read section
Example::
scoped_seqlock_read (&lock, ss_lock) {
// read-side critical section
}
Starts with a lockess pass first. If it fails, restarts the critical section with the lock held.
| #define SEQCNT_LATCH_ZERO | ( | seq_name | ) |
SEQCNT_LATCH_ZERO() - static initializer for seqcount_latch_t @seq_name: Name of the seqcount_latch_t instance
| #define SEQCNT_MUTEX_ZERO | ( | name, | |
| lock | |||
| ) | SEQCOUNT_LOCKNAME_ZERO(name, lock) |
| #define SEQCNT_RAW_SPINLOCK_ZERO | ( | name, | |
| lock | |||
| ) | SEQCOUNT_LOCKNAME_ZERO(name, lock) |
| #define SEQCNT_RWLOCK_ZERO | ( | name, | |
| lock | |||
| ) | SEQCOUNT_LOCKNAME_ZERO(name, lock) |
| #define SEQCNT_SPINLOCK_ZERO | ( | name, | |
| lock | |||
| ) | SEQCOUNT_LOCKNAME_ZERO(name, lock) |
| #define SEQCNT_WW_MUTEX_ZERO | ( | name, | |
| lock | |||
| ) | SEQCOUNT_LOCKNAME_ZERO(name, lock) |
| #define SEQCNT_ZERO | ( | name | ) | { .sequence = 0, SEQCOUNT_DEP_MAP_INIT(name) } |
| #define SEQCOUNT_DEP_MAP_INIT | ( | lockname | ) |
| #define seqcount_latch_init | ( | s | ) | seqcount_init(&(s)->seqcount) |
seqcount_latch_init() - runtime initializer for seqcount_latch_t @s: Pointer to the seqcount_latch_t instance
| #define seqcount_lockdep_reader_access | ( | x | ) |
| #define SEQCOUNT_LOCKNAME | ( | lockname, | |
| locktype, | |||
| preemptible, | |||
| lockbase | |||
| ) |
| #define seqcount_LOCKNAME_init | ( | s, | |
| _lock, | |||
| lockname | |||
| ) |
| #define SEQCOUNT_LOCKNAME_ZERO | ( | seq_name, | |
| assoc_lock | |||
| ) |
| #define seqcount_mutex_init | ( | s, | |
| lock | |||
| ) | seqcount_LOCKNAME_init(s, lock, mutex) |
| #define seqcount_raw_spinlock_init | ( | s, | |
| lock | |||
| ) | seqcount_LOCKNAME_init(s, lock, raw_spinlock) |
| #define seqcount_rwlock_init | ( | s, | |
| lock | |||
| ) | seqcount_LOCKNAME_init(s, lock, rwlock) |
| #define seqcount_spinlock_init | ( | s, | |
| lock | |||
| ) | seqcount_LOCKNAME_init(s, lock, spinlock) |
| #define seqlock_init | ( | sl | ) |
seqlock_init() - dynamic initializer for seqlock_t @sl: Pointer to the seqlock_t instance
| #define seqprop_const_ptr | ( | s | ) | __seqprop(s, const_ptr)(s) |
| #define seqprop_preemptible | ( | s | ) | __seqprop(s, preemptible)(s) |
| #define seqprop_ptr | ( | s | ) | __seqprop(s, ptr)(s) |
| #define seqprop_sequence | ( | s | ) | __seqprop(s, sequence)(s) |
| #define write_seqcount_begin | ( | s | ) |
write_seqcount_begin() - start a seqcount_t write side critical section @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Context: sequence counter write side sections must be serialized and non-preemptible. Preemption will be automatically disabled if and only if the seqcount write serialization lock is associated, and preemptible. If readers can be invoked from hardirq or softirq context, interrupts or bottom halves must be respectively disabled.
| #define write_seqcount_begin_nested | ( | s, | |
| subclass | |||
| ) |
write_seqcount_begin_nested() - start a seqcount_t write section with custom lockdep nesting level @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants @subclass: lockdep nesting level
See Documentation/locking/lockdep-design.rst Context: check write_seqcount_begin()
| #define write_seqcount_end | ( | s | ) |
write_seqcount_end() - end a seqcount_t write side critical section @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
Context: Preemption will be automatically re-enabled if and only if the seqcount write serialization lock is associated, and preemptible.
| #define write_seqcount_invalidate | ( | s | ) | do_write_seqcount_invalidate(seqprop_ptr(s)) |
write_seqcount_invalidate() - invalidate in-progress seqcount_t read side operations @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
After write_seqcount_invalidate, no seqcount_t read side operations will complete successfully and see data older than this.
| #define write_seqlock_irqsave | ( | lock, | |
| flags | |||
| ) | do { flags = __write_seqlock_irqsave(lock); } while (0) |
write_seqlock_irqsave() - start a non-interruptible seqlock_t write section @lock: Pointer to seqlock_t @flags: Stack-allocated storage for saving caller's local interrupt state, to be passed to write_sequnlock_irqrestore().
_irqsave variant of write_seqlock(). Use it only if the read side section, or other write sections, can be invoked from hardirq context.
| enum ss_state |
|
extern |
|
extern |