diff options
author | Rik van Riel <riel@redhat.com> | 2014-09-12 09:12:14 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-09-19 06:35:16 -0400 |
commit | ef8ac06359ddf95431cf6bb04ad2b36fff562328 (patch) | |
tree | a7987f9ce983b4e12e26c92c140ef88a4cd7c838 /include/linux/seqlock.h | |
parent | 2ed903c5485bad0eafdd3d59ff993598736e4f31 (diff) |
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: Rik van Riel <riel@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: prarit@redhat.com
Cc: oleg@redhat.com
Cc: sgruszka@redhat.com
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Link: http://lkml.kernel.org/r/1410527535-9814-2-git-send-email-riel@redhat.com
[ Improved the readability of the code a bit. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/seqlock.h')
-rw-r--r-- | include/linux/seqlock.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index cc359636cfa3..f5df8f687b4d 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h | |||
@@ -456,4 +456,23 @@ read_sequnlock_excl_irqrestore(seqlock_t *sl, unsigned long flags) | |||
456 | spin_unlock_irqrestore(&sl->lock, flags); | 456 | spin_unlock_irqrestore(&sl->lock, flags); |
457 | } | 457 | } |
458 | 458 | ||
459 | static inline unsigned long | ||
460 | read_seqbegin_or_lock_irqsave(seqlock_t *lock, int *seq) | ||
461 | { | ||
462 | unsigned long flags = 0; | ||
463 | |||
464 | if (!(*seq & 1)) /* Even */ | ||
465 | *seq = read_seqbegin(lock); | ||
466 | else /* Odd */ | ||
467 | read_seqlock_excl_irqsave(lock, flags); | ||
468 | |||
469 | return flags; | ||
470 | } | ||
471 | |||
472 | static inline void | ||
473 | done_seqretry_irqrestore(seqlock_t *lock, int seq, unsigned long flags) | ||
474 | { | ||
475 | if (seq & 1) | ||
476 | read_sequnlock_excl_irqrestore(lock, flags); | ||
477 | } | ||
459 | #endif /* __LINUX_SEQLOCK_H */ | 478 | #endif /* __LINUX_SEQLOCK_H */ |