Commit ef8ac063 authored by Rik van Riel's avatar Rik van Riel Committed by Ingo Molnar

seqlock: Add irqsave variant of read_seqbegin_or_lock()

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: default avatarRik van Riel <>
Signed-off-by: default avatarPeter Zijlstra (Intel) <>
Cc: Al Viro <>
Cc: John Stultz <>
Cc: Linus Torvalds <>
Cc: Mathieu Desnoyers <>
Cc: Stephen Boyd <>
Cc: Trond Myklebust <>
[ Improved the readability of the code a bit. ]
Signed-off-by: default avatarIngo Molnar <>
parent 2ed903c5
......@@ -456,4 +456,23 @@ 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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment