@@ -149,21 +149,6 @@ do { \
149149 __SEQ_LOCK((s)->lock = (assoc_lock)); \
150150} while (0)
151151
152- /**
153- * typedef seqcount_spinlock_t - sequence counter with spinlock associated
154- * @seqcount: The real sequence counter
155- * @lock: Pointer to the associated spinlock
156- *
157- * A plain sequence counter with external writer synchronization by a
158- * spinlock. The spinlock is associated to the sequence count in the
159- * static initializer or init function. This enables lockdep to validate
160- * that the write side critical section is properly serialized.
161- */
162- typedef struct seqcount_spinlock {
163- seqcount_t seqcount ;
164- __SEQ_LOCK (spinlock_t * lock );
165- } seqcount_spinlock_t ;
166-
167152/**
168153 * SEQCNT_SPINLOCK_ZERO - static initializer for seqcount_spinlock_t
169154 * @name: Name of the seqcount_spinlock_t instance
@@ -180,21 +165,6 @@ typedef struct seqcount_spinlock {
180165#define seqcount_spinlock_init (s , lock ) \
181166 seqcount_locktype_init(s, lock)
182167
183- /**
184- * typedef seqcount_raw_spinlock_t - sequence count with raw spinlock associated
185- * @seqcount: The real sequence counter
186- * @lock: Pointer to the associated raw spinlock
187- *
188- * A plain sequence counter with external writer synchronization by a
189- * raw spinlock. The raw spinlock is associated to the sequence count in
190- * the static initializer or init function. This enables lockdep to
191- * validate that the write side critical section is properly serialized.
192- */
193- typedef struct seqcount_raw_spinlock {
194- seqcount_t seqcount ;
195- __SEQ_LOCK (raw_spinlock_t * lock );
196- } seqcount_raw_spinlock_t ;
197-
198168/**
199169 * SEQCNT_RAW_SPINLOCK_ZERO - static initializer for seqcount_raw_spinlock_t
200170 * @name: Name of the seqcount_raw_spinlock_t instance
@@ -211,21 +181,6 @@ typedef struct seqcount_raw_spinlock {
211181#define seqcount_raw_spinlock_init (s , lock ) \
212182 seqcount_locktype_init(s, lock)
213183
214- /**
215- * typedef seqcount_rwlock_t - sequence count with rwlock associated
216- * @seqcount: The real sequence counter
217- * @lock: Pointer to the associated rwlock
218- *
219- * A plain sequence counter with external writer synchronization by a
220- * rwlock. The rwlock is associated to the sequence count in the static
221- * initializer or init function. This enables lockdep to validate that
222- * the write side critical section is properly serialized.
223- */
224- typedef struct seqcount_rwlock {
225- seqcount_t seqcount ;
226- __SEQ_LOCK (rwlock_t * lock );
227- } seqcount_rwlock_t ;
228-
229184/**
230185 * SEQCNT_RWLOCK_ZERO - static initializer for seqcount_rwlock_t
231186 * @name: Name of the seqcount_rwlock_t instance
@@ -242,24 +197,6 @@ typedef struct seqcount_rwlock {
242197#define seqcount_rwlock_init (s , lock ) \
243198 seqcount_locktype_init(s, lock)
244199
245- /**
246- * typedef seqcount_mutex_t - sequence count with mutex associated
247- * @seqcount: The real sequence counter
248- * @lock: Pointer to the associated mutex
249- *
250- * A plain sequence counter with external writer synchronization by a
251- * mutex. The mutex is associated to the sequence counter in the static
252- * initializer or init function. This enables lockdep to validate that
253- * the write side critical section is properly serialized.
254- *
255- * The write side API functions write_seqcount_begin()/end() automatically
256- * disable and enable preemption when used with seqcount_mutex_t.
257- */
258- typedef struct seqcount_mutex {
259- seqcount_t seqcount ;
260- __SEQ_LOCK (struct mutex * lock );
261- } seqcount_mutex_t ;
262-
263200/**
264201 * SEQCNT_MUTEX_ZERO - static initializer for seqcount_mutex_t
265202 * @name: Name of the seqcount_mutex_t instance
@@ -276,24 +213,6 @@ typedef struct seqcount_mutex {
276213#define seqcount_mutex_init (s , lock ) \
277214 seqcount_locktype_init(s, lock)
278215
279- /**
280- * typedef seqcount_ww_mutex_t - sequence count with ww_mutex associated
281- * @seqcount: The real sequence counter
282- * @lock: Pointer to the associated ww_mutex
283- *
284- * A plain sequence counter with external writer synchronization by a
285- * ww_mutex. The ww_mutex is associated to the sequence counter in the static
286- * initializer or init function. This enables lockdep to validate that
287- * the write side critical section is properly serialized.
288- *
289- * The write side API functions write_seqcount_begin()/end() automatically
290- * disable and enable preemption when used with seqcount_ww_mutex_t.
291- */
292- typedef struct seqcount_ww_mutex {
293- seqcount_t seqcount ;
294- __SEQ_LOCK (struct ww_mutex * lock );
295- } seqcount_ww_mutex_t ;
296-
297216/**
298217 * SEQCNT_WW_MUTEX_ZERO - static initializer for seqcount_ww_mutex_t
299218 * @name: Name of the seqcount_ww_mutex_t instance
@@ -310,30 +229,50 @@ typedef struct seqcount_ww_mutex {
310229#define seqcount_ww_mutex_init (s , lock ) \
311230 seqcount_locktype_init(s, lock)
312231
313- /*
314- * @preempt: Is the associated write serialization lock preemtpible?
232+ /**
233+ * typedef seqcount_LOCKNAME_t - sequence counter with spinlock associated
234+ * @seqcount: The real sequence counter
235+ * @lock: Pointer to the associated spinlock
236+ *
237+ * A plain sequence counter with external writer synchronization by a
238+ * spinlock. The spinlock is associated to the sequence count in the
239+ * static initializer or init function. This enables lockdep to validate
240+ * that the write side critical section is properly serialized.
315241 */
316- #define SEQCOUNT_LOCKTYPE (locktype , preempt , lockmember ) \
317- static inline seqcount_t * \
318- __seqcount_##locktype##_ptr(seqcount_##locktype##_t *s) \
242+
243+ /*
244+ * SEQCOUNT_LOCKTYPE() - Instantiate seqcount_LOCKNAME_t and helpers
245+ * @locktype: actual typename
246+ * @lockname: name
247+ * @preemptible: preemptibility of above locktype
248+ * @lockmember: argument for lockdep_assert_held()
249+ */
250+ #define SEQCOUNT_LOCKTYPE (locktype , lockname , preemptible , lockmember ) \
251+ typedef struct seqcount_##lockname { \
252+ seqcount_t seqcount; \
253+ __SEQ_LOCK(locktype *lock); \
254+ } seqcount_##lockname##_t; \
255+ \
256+ static __always_inline seqcount_t * \
257+ __seqcount_##lockname##_ptr(seqcount_##lockname##_t *s) \
319258{ \
320259 return &s->seqcount; \
321260} \
322261 \
323- static inline bool \
324- __seqcount_##locktype ##_preemptible(seqcount_##locktype ##_t *s) \
262+ static __always_inline bool \
263+ __seqcount_##lockname ##_preemptible(seqcount_##lockname ##_t *s) \
325264{ \
326- return preempt; \
265+ return preemptible; \
327266} \
328267 \
329- static inline void \
330- __seqcount_##locktype ##_assert(seqcount_##locktype ##_t *s) \
268+ static __always_inline void \
269+ __seqcount_##lockname ##_assert(seqcount_##lockname ##_t *s) \
331270{ \
332271 __SEQ_LOCK(lockdep_assert_held(lockmember)); \
333272}
334273
335274/*
336- * Similar hooks, but for plain seqcount_t
275+ * __seqprop() for seqcount_t
337276 */
338277
339278static inline seqcount_t * __seqcount_ptr (seqcount_t * s )
@@ -351,17 +290,14 @@ static inline void __seqcount_assert(seqcount_t *s)
351290 lockdep_assert_preemption_disabled ();
352291}
353292
354- /*
355- * @s: Pointer to seqcount_locktype_t, generated hooks first parameter.
356- */
357- SEQCOUNT_LOCKTYPE (raw_spinlock , false, s -> lock )
358- SEQCOUNT_LOCKTYPE (spinlock , false, s -> lock )
359- SEQCOUNT_LOCKTYPE (rwlock , false, s -> lock )
360- SEQCOUNT_LOCKTYPE (mutex , true, s -> lock )
361- SEQCOUNT_LOCKTYPE (ww_mutex , true, & s -> lock -> base )
362-
363- #define __seqprop_case (s , locktype , prop ) \
364- seqcount_##locktype##_t: __seqcount_##locktype##_##prop((void *)(s))
293+ SEQCOUNT_LOCKTYPE (raw_spinlock_t , raw_spinlock , false, s -> lock )
294+ SEQCOUNT_LOCKTYPE (spinlock_t , spinlock , false, s -> lock )
295+ SEQCOUNT_LOCKTYPE (rwlock_t , rwlock , false, s -> lock )
296+ SEQCOUNT_LOCKTYPE (struct mutex , mutex , true, s -> lock )
297+ SEQCOUNT_LOCKTYPE (struct ww_mutex , ww_mutex , true, & s -> lock -> base )
298+
299+ #define __seqprop_case (s , lockname , prop ) \
300+ seqcount_##lockname##_t: __seqcount_##lockname##_##prop((void *)(s))
365301
366302#define __seqprop (s , prop ) _Generic(*(s), \
367303 seqcount_t: __seqcount_##prop((void *)(s)), \
0 commit comments