lkml.org 
[lkml]   [2014]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -tip 1/2] seqlock: add irqsave variant of read_seqbegin_or_lock
Date
From: Rik van Riel <riel@redhat.com>

There are cases where read_seqbegin_or_lock needs to block irqs,
because the seqlock in question nests inside a lock that is also
be taken from irq context.

Add read_seqbegin_or_lock_irqsave and done_seqretry_irqrestore, which
are almost identical to read_seqbegin_or_lock and done_seqretry.

Signed-off-by: Rik van Riel <riel@redhat.com>
---
include/linux/seqlock.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index cc35963..4364cd3 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -456,4 +456,21 @@ read_sequnlock_excl_irqrestore(seqlock_t *sl, unsigned long flags)
spin_unlock_irqrestore(&sl->lock, flags);
}

+static inline unsigned long read_seqbegin_or_lock_irqsave(seqlock_t *lock,
+ int *seq)
+{
+ unsigned long flags = 0;
+ if (!(*seq & 1)) /* Even */
+ *seq = read_seqbegin(lock);
+ else /* Odd */
+ read_seqlock_excl_irqsave(lock, flags);
+ return flags;
+}
+
+static inline void done_seqretry_irqrestore(seqlock_t *lock, int seq,
+ unsigned long flags)
+{
+ if (seq & 1)
+ read_sequnlock_excl_irqrestore(lock, flags);
+}
#endif /* __LINUX_SEQLOCK_H */
--
1.9.3


\
 
 \ /
  Last update: 2014-09-12 16:01    [W:0.087 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site