On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote:

> #define SEQCOUNT_LOCKTYPE(name, locktype, preempt, lockmember)                
> \
> typedef struct seqcount_##name {                                      \
>       seqcount_t      seqcount;                                       \
>       __SEQCOUNT_LOCKDEP(locktype *lock);                             \
> } seqcount_##name##_t;                                                        
> \
>                                                                       \
> static __always_inline void                                           \
> seqcount_##name##_init(seqcount_##name##_t *s, locktype *l)           \
> {                                                                     \
>       seqcount_init(&s->seqcount);                                    \
>       __SEQCOUNT_LOCKDEP(s->lock = l);                                \
> }                                                                     \
>                                                                       \
> static __always_inline __seqprop_ptr_t                                        
> \
> __seqprop_##name##_ptr(seqcount_##name##_t *s)                                
> \
> {                                                                     \
>       return &s->seqcount;                                            \
> }                                                                     \
>                                                                       \
> static __always_inline __seqprop_preempt_t                            \
> __seqprop_##name##_preempt(seqcount_##name##_t *s)                    \
> {                                                                     \
>       return preempt;                                                 \
> }                                                                     \
>                                                                       \
> static __always_inline __seqprop_assert_t                             \
> __seqprop_##name##_assert(seqcount_##name##_t *s)                     \
> {                                                                     \
>       __SEQCOUNT_LOCKDEP(lockdep_assert_held(s->lockmember));         \
> }

For PREEMPT_RT's magic thing, you can add:

static __always_inline void                                             \
__seqprop_##name##_lock(seqcount_##name##_t *s)                         \
{                                                                       \
        if (!__SEQ_RT || !preempt)                                      \
                return;                                                 \
                                                                        \
        lockbase##_lock(&s->lock);                                      \
        lockbase##_unlock(&s->lock);                                    \
}

and:

#define __rt_lock_unlock_associated_sleeping_lock(s) __seqprop(s, lock)

Reply via email to