@@ -149,21 +149,6 @@ do { \
149
149
__SEQ_LOCK((s)->lock = (assoc_lock)); \
150
150
} while (0)
151
151
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
-
167
152
/**
168
153
* SEQCNT_SPINLOCK_ZERO - static initializer for seqcount_spinlock_t
169
154
* @name: Name of the seqcount_spinlock_t instance
@@ -180,21 +165,6 @@ typedef struct seqcount_spinlock {
180
165
#define seqcount_spinlock_init (s , lock ) \
181
166
seqcount_locktype_init(s, lock)
182
167
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
-
198
168
/**
199
169
* SEQCNT_RAW_SPINLOCK_ZERO - static initializer for seqcount_raw_spinlock_t
200
170
* @name: Name of the seqcount_raw_spinlock_t instance
@@ -211,21 +181,6 @@ typedef struct seqcount_raw_spinlock {
211
181
#define seqcount_raw_spinlock_init (s , lock ) \
212
182
seqcount_locktype_init(s, lock)
213
183
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
-
229
184
/**
230
185
* SEQCNT_RWLOCK_ZERO - static initializer for seqcount_rwlock_t
231
186
* @name: Name of the seqcount_rwlock_t instance
@@ -242,24 +197,6 @@ typedef struct seqcount_rwlock {
242
197
#define seqcount_rwlock_init (s , lock ) \
243
198
seqcount_locktype_init(s, lock)
244
199
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
-
263
200
/**
264
201
* SEQCNT_MUTEX_ZERO - static initializer for seqcount_mutex_t
265
202
* @name: Name of the seqcount_mutex_t instance
@@ -276,24 +213,6 @@ typedef struct seqcount_mutex {
276
213
#define seqcount_mutex_init (s , lock ) \
277
214
seqcount_locktype_init(s, lock)
278
215
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
-
297
216
/**
298
217
* SEQCNT_WW_MUTEX_ZERO - static initializer for seqcount_ww_mutex_t
299
218
* @name: Name of the seqcount_ww_mutex_t instance
@@ -310,30 +229,50 @@ typedef struct seqcount_ww_mutex {
310
229
#define seqcount_ww_mutex_init (s , lock ) \
311
230
seqcount_locktype_init(s, lock)
312
231
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.
315
241
*/
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) \
319
258
{ \
320
259
return &s->seqcount; \
321
260
} \
322
261
\
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) \
325
264
{ \
326
- return preempt; \
265
+ return preemptible; \
327
266
} \
328
267
\
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) \
331
270
{ \
332
271
__SEQ_LOCK(lockdep_assert_held(lockmember)); \
333
272
}
334
273
335
274
/*
336
- * Similar hooks, but for plain seqcount_t
275
+ * __seqprop() for seqcount_t
337
276
*/
338
277
339
278
static inline seqcount_t * __seqcount_ptr (seqcount_t * s )
@@ -351,17 +290,14 @@ static inline void __seqcount_assert(seqcount_t *s)
351
290
lockdep_assert_preemption_disabled ();
352
291
}
353
292
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))
365
301
366
302
#define __seqprop (s , prop ) _Generic(*(s), \
367
303
seqcount_t: __seqcount_##prop((void *)(s)), \
0 commit comments