Skip to content

Commit 5cdd255

Browse files
a-darwishPeter Zijlstra
authored andcommitted
seqlock: Use unique prefix for seqcount_t property accessors
At seqlock.h, the following set of functions: - __seqcount_ptr() - __seqcount_preemptible() - __seqcount_assert() act as plain seqcount_t "property" accessors. Meanwhile, the following group: - __seqcount_ptr() - __seqcount_lock_preemptible() - __seqcount_assert_lock_held() act as the equivalent set, but in the generic form, taking either seqcount_t or any of the seqcount_LOCKNAME_t variants. This is quite confusing, especially the first member where it is called exactly the same in both groups. Differentiate the first group by using "__seqprop" as prefix, and also use that same prefix for all of seqcount_LOCKNAME_t property accessors. While at it, constify the property accessors first parameter when appropriate. References: 55f3560 ("seqlock: Extend seqcount API with associated locks") 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-3-a.darwish@linutronix.de
1 parent 6dd699b commit 5cdd255

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

include/linux/seqlock.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
157157
*/
158158

159159
/*
160-
* SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers
160+
* SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers
161+
* seqprop_LOCKNAME_*() - Property accessors for seqcount_LOCKNAME_t
162+
*
161163
* @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t
162164
* @locktype: LOCKNAME canonical C data type
163165
* @preemptible: preemptibility of above lockname
@@ -177,19 +179,19 @@ seqcount_##lockname##_init(seqcount_##lockname##_t *s, locktype *lock) \
177179
} \
178180
\
179181
static __always_inline seqcount_t * \
180-
__seqcount_##lockname##_ptr(seqcount_##lockname##_t *s) \
182+
__seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \
181183
{ \
182184
return &s->seqcount; \
183185
} \
184186
\
185187
static __always_inline bool \
186-
__seqcount_##lockname##_preemptible(seqcount_##lockname##_t *s) \
188+
__seqprop_##lockname##_preemptible(const seqcount_##lockname##_t *s) \
187189
{ \
188190
return preemptible; \
189191
} \
190192
\
191193
static __always_inline void \
192-
__seqcount_##lockname##_assert(seqcount_##lockname##_t *s) \
194+
__seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \
193195
{ \
194196
__SEQ_LOCK(lockdep_assert_held(lockmember)); \
195197
}
@@ -198,17 +200,17 @@ __seqcount_##lockname##_assert(seqcount_##lockname##_t *s) \
198200
* __seqprop() for seqcount_t
199201
*/
200202

201-
static inline seqcount_t *__seqcount_ptr(seqcount_t *s)
203+
static inline seqcount_t *__seqprop_ptr(seqcount_t *s)
202204
{
203205
return s;
204206
}
205207

206-
static inline bool __seqcount_preemptible(seqcount_t *s)
208+
static inline bool __seqprop_preemptible(const seqcount_t *s)
207209
{
208210
return false;
209211
}
210212

211-
static inline void __seqcount_assert(seqcount_t *s)
213+
static inline void __seqprop_assert(const seqcount_t *s)
212214
{
213215
lockdep_assert_preemption_disabled();
214216
}
@@ -237,10 +239,10 @@ SEQCOUNT_LOCKNAME(ww_mutex, struct ww_mutex, true, &s->lock->base)
237239
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
238240

239241
#define __seqprop_case(s, lockname, prop) \
240-
seqcount_##lockname##_t: __seqcount_##lockname##_##prop((void *)(s))
242+
seqcount_##lockname##_t: __seqprop_##lockname##_##prop((void *)(s))
241243

242244
#define __seqprop(s, prop) _Generic(*(s), \
243-
seqcount_t: __seqcount_##prop((void *)(s)), \
245+
seqcount_t: __seqprop_##prop((void *)(s)), \
244246
__seqprop_case((s), raw_spinlock, prop), \
245247
__seqprop_case((s), spinlock, prop), \
246248
__seqprop_case((s), rwlock, prop), \

0 commit comments

Comments
 (0)