Skip to content

Commit 6dd699b

Browse files
a-darwishPeter Zijlstra
authored andcommitted
seqlock: seqcount_LOCKNAME_t: Standardize naming convention
At seqlock.h, sequence counters with associated locks are either called seqcount_LOCKNAME_t, seqcount_LOCKTYPE_t, or seqcount_locktype_t. Standardize on seqcount_LOCKNAME_t for all instances in comments, kernel-doc, and SEQCOUNT_LOCKNAME() generative macro paramters. Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200904153231.11994-2-a.darwish@linutronix.de
1 parent 0c9794c commit 6dd699b

1 file changed

Lines changed: 40 additions & 39 deletions

File tree

include/linux/seqlock.h

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*
5454
* If the write serialization mechanism is one of the common kernel
5555
* locking primitives, use a sequence counter with associated lock
56-
* (seqcount_LOCKTYPE_t) instead.
56+
* (seqcount_LOCKNAME_t) instead.
5757
*
5858
* If it's desired to automatically handle the sequence counter writer
5959
* serialization and non-preemptibility requirements, use a sequential
@@ -117,7 +117,7 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
117117
#define SEQCNT_ZERO(name) { .sequence = 0, SEQCOUNT_DEP_MAP_INIT(name) }
118118

119119
/*
120-
* Sequence counters with associated locks (seqcount_LOCKTYPE_t)
120+
* Sequence counters with associated locks (seqcount_LOCKNAME_t)
121121
*
122122
* A sequence counter which associates the lock used for writer
123123
* serialization at initialization time. This enables lockdep to validate
@@ -138,30 +138,32 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
138138
#endif
139139

140140
/**
141-
* typedef seqcount_LOCKNAME_t - sequence counter with LOCKTYPE associated
141+
* typedef seqcount_LOCKNAME_t - sequence counter with LOCKNAME associated
142142
* @seqcount: The real sequence counter
143-
* @lock: Pointer to the associated spinlock
143+
* @lock: Pointer to the associated lock
144144
*
145-
* A plain sequence counter with external writer synchronization by a
146-
* spinlock. The spinlock is associated to the sequence count in the
145+
* A plain sequence counter with external writer synchronization by
146+
* LOCKNAME @lock. The lock is associated to the sequence counter in the
147147
* static initializer or init function. This enables lockdep to validate
148148
* that the write side critical section is properly serialized.
149+
*
150+
* LOCKNAME: raw_spinlock, spinlock, rwlock, mutex, or ww_mutex.
149151
*/
150152

151153
/*
152154
* seqcount_LOCKNAME_init() - runtime initializer for seqcount_LOCKNAME_t
153155
* @s: Pointer to the seqcount_LOCKNAME_t instance
154-
* @lock: Pointer to the associated LOCKTYPE
156+
* @lock: Pointer to the associated lock
155157
*/
156158

157159
/*
158-
* SEQCOUNT_LOCKTYPE() - Instantiate seqcount_LOCKNAME_t and helpers
159-
* @locktype: actual typename
160-
* @lockname: name
161-
* @preemptible: preemptibility of above locktype
160+
* SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers
161+
* @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t
162+
* @locktype: LOCKNAME canonical C data type
163+
* @preemptible: preemptibility of above lockname
162164
* @lockmember: argument for lockdep_assert_held()
163165
*/
164-
#define SEQCOUNT_LOCKTYPE(locktype, lockname, preemptible, lockmember) \
166+
#define SEQCOUNT_LOCKNAME(lockname, locktype, preemptible, lockmember) \
165167
typedef struct seqcount_##lockname { \
166168
seqcount_t seqcount; \
167169
__SEQ_LOCK(locktype *lock); \
@@ -211,29 +213,28 @@ static inline void __seqcount_assert(seqcount_t *s)
211213
lockdep_assert_preemption_disabled();
212214
}
213215

214-
SEQCOUNT_LOCKTYPE(raw_spinlock_t, raw_spinlock, false, s->lock)
215-
SEQCOUNT_LOCKTYPE(spinlock_t, spinlock, false, s->lock)
216-
SEQCOUNT_LOCKTYPE(rwlock_t, rwlock, false, s->lock)
217-
SEQCOUNT_LOCKTYPE(struct mutex, mutex, true, s->lock)
218-
SEQCOUNT_LOCKTYPE(struct ww_mutex, ww_mutex, true, &s->lock->base)
216+
SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, s->lock)
217+
SEQCOUNT_LOCKNAME(spinlock, spinlock_t, false, s->lock)
218+
SEQCOUNT_LOCKNAME(rwlock, rwlock_t, false, s->lock)
219+
SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock)
220+
SEQCOUNT_LOCKNAME(ww_mutex, struct ww_mutex, true, &s->lock->base)
219221

220222
/*
221223
* SEQCNT_LOCKNAME_ZERO - static initializer for seqcount_LOCKNAME_t
222224
* @name: Name of the seqcount_LOCKNAME_t instance
223-
* @lock: Pointer to the associated LOCKTYPE
225+
* @lock: Pointer to the associated LOCKNAME
224226
*/
225227

226-
#define SEQCOUNT_LOCKTYPE_ZERO(seq_name, assoc_lock) { \
228+
#define SEQCOUNT_LOCKNAME_ZERO(seq_name, assoc_lock) { \
227229
.seqcount = SEQCNT_ZERO(seq_name.seqcount), \
228230
__SEQ_LOCK(.lock = (assoc_lock)) \
229231
}
230232

231-
#define SEQCNT_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
232-
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
233-
#define SEQCNT_RWLOCK_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
234-
#define SEQCNT_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
235-
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKTYPE_ZERO(name, lock)
236-
233+
#define SEQCNT_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
234+
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
235+
#define SEQCNT_RWLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
236+
#define SEQCNT_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
237+
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
237238

238239
#define __seqprop_case(s, lockname, prop) \
239240
seqcount_##lockname##_t: __seqcount_##lockname##_##prop((void *)(s))
@@ -252,7 +253,7 @@ SEQCOUNT_LOCKTYPE(struct ww_mutex, ww_mutex, true, &s->lock->base)
252253

253254
/**
254255
* __read_seqcount_begin() - begin a seqcount_t read section w/o barrier
255-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
256+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
256257
*
257258
* __read_seqcount_begin is like read_seqcount_begin, but has no smp_rmb()
258259
* barrier. Callers should ensure that smp_rmb() or equivalent ordering is
@@ -283,7 +284,7 @@ static inline unsigned __read_seqcount_t_begin(const seqcount_t *s)
283284

284285
/**
285286
* raw_read_seqcount_begin() - begin a seqcount_t read section w/o lockdep
286-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
287+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
287288
*
288289
* Return: count to be passed to read_seqcount_retry()
289290
*/
@@ -299,7 +300,7 @@ static inline unsigned raw_read_seqcount_t_begin(const seqcount_t *s)
299300

300301
/**
301302
* read_seqcount_begin() - begin a seqcount_t read critical section
302-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
303+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
303304
*
304305
* Return: count to be passed to read_seqcount_retry()
305306
*/
@@ -314,7 +315,7 @@ static inline unsigned read_seqcount_t_begin(const seqcount_t *s)
314315

315316
/**
316317
* raw_read_seqcount() - read the raw seqcount_t counter value
317-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
318+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
318319
*
319320
* raw_read_seqcount opens a read critical section of the given
320321
* seqcount_t, without any lockdep checking, and without checking or
@@ -337,7 +338,7 @@ static inline unsigned raw_read_seqcount_t(const seqcount_t *s)
337338
/**
338339
* raw_seqcount_begin() - begin a seqcount_t read critical section w/o
339340
* lockdep and w/o counter stabilization
340-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
341+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
341342
*
342343
* raw_seqcount_begin opens a read critical section of the given
343344
* seqcount_t. Unlike read_seqcount_begin(), this function will not wait
@@ -365,7 +366,7 @@ static inline unsigned raw_seqcount_t_begin(const seqcount_t *s)
365366

366367
/**
367368
* __read_seqcount_retry() - end a seqcount_t read section w/o barrier
368-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
369+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
369370
* @start: count, from read_seqcount_begin()
370371
*
371372
* __read_seqcount_retry is like read_seqcount_retry, but has no smp_rmb()
@@ -389,7 +390,7 @@ static inline int __read_seqcount_t_retry(const seqcount_t *s, unsigned start)
389390

390391
/**
391392
* read_seqcount_retry() - end a seqcount_t read critical section
392-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
393+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
393394
* @start: count, from read_seqcount_begin()
394395
*
395396
* read_seqcount_retry closes the read critical section of given
@@ -409,7 +410,7 @@ static inline int read_seqcount_t_retry(const seqcount_t *s, unsigned start)
409410

410411
/**
411412
* raw_write_seqcount_begin() - start a seqcount_t write section w/o lockdep
412-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
413+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
413414
*/
414415
#define raw_write_seqcount_begin(s) \
415416
do { \
@@ -428,7 +429,7 @@ static inline void raw_write_seqcount_t_begin(seqcount_t *s)
428429

429430
/**
430431
* raw_write_seqcount_end() - end a seqcount_t write section w/o lockdep
431-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
432+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
432433
*/
433434
#define raw_write_seqcount_end(s) \
434435
do { \
@@ -448,7 +449,7 @@ static inline void raw_write_seqcount_t_end(seqcount_t *s)
448449
/**
449450
* write_seqcount_begin_nested() - start a seqcount_t write section with
450451
* custom lockdep nesting level
451-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
452+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
452453
* @subclass: lockdep nesting level
453454
*
454455
* See Documentation/locking/lockdep-design.rst
@@ -471,7 +472,7 @@ static inline void write_seqcount_t_begin_nested(seqcount_t *s, int subclass)
471472

472473
/**
473474
* write_seqcount_begin() - start a seqcount_t write side critical section
474-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
475+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
475476
*
476477
* write_seqcount_begin opens a write side critical section of the given
477478
* seqcount_t.
@@ -497,7 +498,7 @@ static inline void write_seqcount_t_begin(seqcount_t *s)
497498

498499
/**
499500
* write_seqcount_end() - end a seqcount_t write side critical section
500-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
501+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
501502
*
502503
* The write section must've been opened with write_seqcount_begin().
503504
*/
@@ -517,7 +518,7 @@ static inline void write_seqcount_t_end(seqcount_t *s)
517518

518519
/**
519520
* raw_write_seqcount_barrier() - do a seqcount_t write barrier
520-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
521+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
521522
*
522523
* This can be used to provide an ordering guarantee instead of the usual
523524
* consistency guarantee. It is one wmb cheaper, because it can collapse
@@ -571,7 +572,7 @@ static inline void raw_write_seqcount_t_barrier(seqcount_t *s)
571572
/**
572573
* write_seqcount_invalidate() - invalidate in-progress seqcount_t read
573574
* side operations
574-
* @s: Pointer to seqcount_t or any of the seqcount_locktype_t variants
575+
* @s: Pointer to seqcount_t or any of the seqcount_LOCKNAME_t variants
575576
*
576577
* After write_seqcount_invalidate, no seqcount_t read side operations
577578
* will complete successfully and see data older than this.

0 commit comments

Comments
 (0)