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 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)

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