From: riel@redhat.com
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
prarit@redhat.com, oleg@redhat.com, sgruszka@redhat.com
Subject: [PATCH -tip 1/2] seqlock: add irqsave variant of read_seqbegin_or_lock
Date: Fri, 12 Sep 2014 09:12:14 -0400 [thread overview]
Message-ID: <1410527535-9814-2-git-send-email-riel@redhat.com> (raw)
In-Reply-To: <1410527535-9814-1-git-send-email-riel@redhat.com>
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
next prev parent reply other threads:[~2014-09-12 13:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 13:12 [PATCH -tip 0/2] fix lock inversion in lockless sys_times() riel
2014-09-12 13:12 ` riel [this message]
2014-09-19 11:44 ` [tip:sched/core] seqlock: Add irqsave variant of read_seqbegin_or_lock() tip-bot for Rik van Riel
2014-09-12 13:12 ` [PATCH -tip 2/2] sched,time: fix lock inversion in thread_group_cputime riel
2014-09-19 11:44 ` [tip:sched/core] sched, time: Fix lock inversion in thread_group_cputime() tip-bot for Rik van Riel
2014-09-14 9:22 ` [PATCH -tip 0/2] fix lock inversion in lockless sys_times() Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410527535-9814-2-git-send-email-riel@redhat.com \
--to=riel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=prarit@redhat.com \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox