diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2009-07-25 19:27:54 +0200 |
|---|---|---|
| committer | Clark Williams <williams@redhat.com> | 2012-02-15 10:32:36 -0600 |
| commit | 52ceb95cd89055acff2deabe509a5bea1329b730 (patch) | |
| tree | ec2092eae91210960993477d414d0e40f27b1711 /include/linux | |
| parent | e91e1cf3693674395316f96a11b953a69f99633c (diff) | |
seqlock: Create raw_seqlock
raw_seqlock_t will be used to annotate seqlocks which can not be
converted to sleeping locks in preempt-rt
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/seqlock.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 11a9073926f1..e26235357202 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -152,6 +152,11 @@ static inline void write_seqcount_barrier(seqcount_t *s) typedef struct { struct seqcount seqcount; + raw_spinlock_t lock; +} raw_seqlock_t; + +typedef struct { + struct seqcount seqcount; spinlock_t lock; } seqlock_t; @@ -159,6 +164,21 @@ typedef struct { * These macros triggered gcc-3.x compile-time problems. We think these are * OK now. Be cautious. */ +#define __RAW_SEQLOCK_UNLOCKED(lockname) \ + { \ + .seqcount = SEQCNT_ZERO, \ + .lock = __RAW_SPIN_LOCK_UNLOCKED(lockname) \ + } + +#define raw_seqlock_init(x) \ + do { \ + seqcount_init(&(x)->seqcount); \ + raw_spin_lock_init(&(x)->lock); \ + } while (0) + +#define DEFINE_RAW_SEQLOCK(x) \ + raw_seqlock_t x = __RAW_SEQLOCK_UNLOCKED(x) + #define __SEQLOCK_UNLOCKED(lockname) \ { \ .seqcount = SEQCNT_ZERO, \ @@ -182,6 +202,49 @@ typedef struct { * Acts like a normal spin_lock/unlock. * Don't need preempt_disable() because that is in the spin_lock already. */ +static inline void raw_write_seqlock(raw_seqlock_t *sl) +{ + raw_spin_lock(&sl->lock); + write_seqcount_begin(&sl->seqcount); +} + +static inline void raw_write_sequnlock(raw_seqlock_t *sl) +{ + write_seqcount_end(&sl->seqcount); + raw_spin_unlock(&sl->lock); +} + +static inline void raw_write_seqlock_irq(raw_seqlock_t *sl) +{ + raw_spin_lock_irq(&sl->lock); + write_seqcount_begin(&sl->seqcount); +} + +static inline void raw_write_sequnlock_irq(raw_seqlock_t *sl) +{ + write_seqcount_end(&sl->seqcount); + raw_spin_unlock_irq(&sl->lock); +} + +static inline unsigned long __raw_write_seqlock_irqsave(raw_seqlock_t *sl) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&sl->lock, flags); + write_seqcount_begin(&sl->seqcount); + return flags; +} + +#define raw_write_seqlock_irqsave(lock, flags) \ + do { flags = __raw_write_seqlock_irqsave(lock); } while (0) + +static inline void +raw_write_sequnlock_irqrestore(raw_seqlock_t *sl, unsigned long flags) +{ + write_seqcount_end(&sl->seqcount); + raw_spin_unlock_irqrestore(&sl->lock, flags); +} + static inline void write_seqlock(seqlock_t *sl) { spin_lock(&sl->lock); |
