Skip to content

Commit 267580d

Browse files
author
peterz@infradead.org
committed
seqlock: Unbreak lockdep
seqcount_LOCKNAME_init() needs to be a macro due to the lockdep annotation in seqcount_init(). Since a macro cannot define another macro, we need to effectively revert commit: e4e9ab3 ("seqlock: Fold seqcount_LOCKNAME_init() definition"). Fixes: e4e9ab3 ("seqlock: Fold seqcount_LOCKNAME_init() definition") Reported-by: Qian Cai <cai@redhat.com> Debugged-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Qian Cai <cai@redhat.com> Link: https://lkml.kernel.org/r/20200915143028.GB2674@hirez.programming.kicks-ass.net
1 parent 1909760 commit 267580d

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

include/linux/seqlock.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
173173
* @lock: Pointer to the associated lock
174174
*/
175175

176+
#define seqcount_LOCKNAME_init(s, _lock, lockname) \
177+
do { \
178+
seqcount_##lockname##_t *____s = (s); \
179+
seqcount_init(&____s->seqcount); \
180+
__SEQ_LOCK(____s->lock = (_lock)); \
181+
} while (0)
182+
183+
#define seqcount_raw_spinlock_init(s, lock) seqcount_LOCKNAME_init(s, lock, raw_spinlock)
184+
#define seqcount_spinlock_init(s, lock) seqcount_LOCKNAME_init(s, lock, spinlock)
185+
#define seqcount_rwlock_init(s, lock) seqcount_LOCKNAME_init(s, lock, rwlock);
186+
#define seqcount_mutex_init(s, lock) seqcount_LOCKNAME_init(s, lock, mutex);
187+
#define seqcount_ww_mutex_init(s, lock) seqcount_LOCKNAME_init(s, lock, ww_mutex);
188+
176189
/*
177190
* SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers
178191
* seqprop_LOCKNAME_*() - Property accessors for seqcount_LOCKNAME_t
@@ -190,13 +203,6 @@ typedef struct seqcount_##lockname { \
190203
__SEQ_LOCK(locktype *lock); \
191204
} seqcount_##lockname##_t; \
192205
\
193-
static __always_inline void \
194-
seqcount_##lockname##_init(seqcount_##lockname##_t *s, locktype *lock) \
195-
{ \
196-
seqcount_init(&s->seqcount); \
197-
__SEQ_LOCK(s->lock = lock); \
198-
} \
199-
\
200206
static __always_inline seqcount_t * \
201207
__seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \
202208
{ \
@@ -284,8 +290,8 @@ SEQCOUNT_LOCKNAME(ww_mutex, struct ww_mutex, true, &s->lock->base, ww_mu
284290
__SEQ_LOCK(.lock = (assoc_lock)) \
285291
}
286292

287-
#define SEQCNT_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
288293
#define SEQCNT_RAW_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
294+
#define SEQCNT_SPINLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
289295
#define SEQCNT_RWLOCK_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
290296
#define SEQCNT_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
291297
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)

0 commit comments

Comments
 (0)