lkml.org 
[lkml]   [2020]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks
On Wed, Jul 08, 2020 at 04:13:32PM +0200, Peter Zijlstra wrote:
> 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)

Or possible have it like:

if (!__SEQ_RT || !preempt)
return smp_cond_load_relaxed(&s->seqcount->sequence, !(VAL & 1));

lockbase##_lock(&s->lock);
lockbase##_unlock(&s->lock);

return READ_ONCE(s->seqcount->sequence);

and then replace most of __read_seqcount_begin() with it.

\
 
 \ /
  Last update: 2020-07-08 16:26    [W:0.243 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site