Commit 5cdd2557 authored by Ahmed S. Darwish's avatar Ahmed S. Darwish Committed by Peter Zijlstra

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: 55f3560d ("seqlock: Extend seqcount API with associated locks")
Signed-off-by: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200904153231.11994-3-a.darwish@linutronix.de
parent 6dd699b1
...@@ -157,7 +157,9 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) ...@@ -157,7 +157,9 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
*/ */
/* /*
* SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers * SEQCOUNT_LOCKNAME() - Instantiate seqcount_LOCKNAME_t and helpers
* seqprop_LOCKNAME_*() - Property accessors for seqcount_LOCKNAME_t
*
* @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t * @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t
* @locktype: LOCKNAME canonical C data type * @locktype: LOCKNAME canonical C data type
* @preemptible: preemptibility of above lockname * @preemptible: preemptibility of above lockname
...@@ -177,19 +179,19 @@ seqcount_##lockname##_init(seqcount_##lockname##_t *s, locktype *lock) \ ...@@ -177,19 +179,19 @@ seqcount_##lockname##_init(seqcount_##lockname##_t *s, locktype *lock) \
} \ } \
\ \
static __always_inline seqcount_t * \ static __always_inline seqcount_t * \
__seqcount_##lockname##_ptr(seqcount_##lockname##_t *s) \ __seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \
{ \ { \
return &s->seqcount; \ return &s->seqcount; \
} \ } \
\ \
static __always_inline bool \ static __always_inline bool \
__seqcount_##lockname##_preemptible(seqcount_##lockname##_t *s) \ __seqprop_##lockname##_preemptible(const seqcount_##lockname##_t *s) \
{ \ { \
return preemptible; \ return preemptible; \
} \ } \
\ \
static __always_inline void \ static __always_inline void \
__seqcount_##lockname##_assert(seqcount_##lockname##_t *s) \ __seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \
{ \ { \
__SEQ_LOCK(lockdep_assert_held(lockmember)); \ __SEQ_LOCK(lockdep_assert_held(lockmember)); \
} }
...@@ -198,17 +200,17 @@ __seqcount_##lockname##_assert(seqcount_##lockname##_t *s) \ ...@@ -198,17 +200,17 @@ __seqcount_##lockname##_assert(seqcount_##lockname##_t *s) \
* __seqprop() for seqcount_t * __seqprop() for seqcount_t
*/ */
static inline seqcount_t *__seqcount_ptr(seqcount_t *s) static inline seqcount_t *__seqprop_ptr(seqcount_t *s)
{ {
return s; return s;
} }
static inline bool __seqcount_preemptible(seqcount_t *s) static inline bool __seqprop_preemptible(const seqcount_t *s)
{ {
return false; return false;
} }
static inline void __seqcount_assert(seqcount_t *s) static inline void __seqprop_assert(const seqcount_t *s)
{ {
lockdep_assert_preemption_disabled(); lockdep_assert_preemption_disabled();
} }
...@@ -237,10 +239,10 @@ SEQCOUNT_LOCKNAME(ww_mutex, struct ww_mutex, true, &s->lock->base) ...@@ -237,10 +239,10 @@ SEQCOUNT_LOCKNAME(ww_mutex, struct ww_mutex, true, &s->lock->base)
#define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock) #define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock)
#define __seqprop_case(s, lockname, prop) \ #define __seqprop_case(s, lockname, prop) \
seqcount_##lockname##_t: __seqcount_##lockname##_##prop((void *)(s)) seqcount_##lockname##_t: __seqprop_##lockname##_##prop((void *)(s))
#define __seqprop(s, prop) _Generic(*(s), \ #define __seqprop(s, prop) _Generic(*(s), \
seqcount_t: __seqcount_##prop((void *)(s)), \ seqcount_t: __seqprop_##prop((void *)(s)), \
__seqprop_case((s), raw_spinlock, prop), \ __seqprop_case((s), raw_spinlock, prop), \
__seqprop_case((s), spinlock, prop), \ __seqprop_case((s), spinlock, prop), \
__seqprop_case((s), rwlock, prop), \ __seqprop_case((s), rwlock, prop), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment