From: John Stultz <john.stultz@linaro.org> To: LKML <linux-kernel@vger.kernel.org> Cc: "John Stultz" <john.stultz@linaro.org>, "Krzysztof Hałasa" <khalasa@piap.pl>, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "Willy Tarreau" <w@1wt.eu>, "Ingo Molnar" <mingo@kernel.org>, "Peter Zijlstra" <peterz@infradead.org>, "Stephen Boyd" <sboyd@codeaurora.org>, "Linus Torvalds" <torvalds@linux-foundation.org>, linux-arm-kernel@lists.infradead.org Subject: [PATCH] sched_clock: Disable seqlock lockdep usage in sched_clock Date: Thu, 2 Jan 2014 13:54:46 -0800 [thread overview] Message-ID: <1388699686-4834-1-git-send-email-john.stultz@linaro.org> (raw) In-Reply-To: <52C5DB5B.9050604@linaro.org> Unforunately the seqlock lockdep enablmenet can't be used in sched_clock, since the lockdep infrastructure eventually calls into sched_clock, which causes a deadlock. Thus, this patch adds _no_lockdep() seqlock methods for the writer side, and changes all generic sched_clock usage to use the _no_lockdep methods. This solves the issue I was able to reproduce, but it would be good to get Krzysztof to confirm it solves his problem. Cc: Krzysztof Hałasa <khalasa@piap.pl> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Willy Tarreau <w@1wt.eu> Cc: Ingo Molnar <mingo@kernel.org>, Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-arm-kernel@lists.infradead.org Reported-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: John Stultz <john.stultz@linaro.org> --- include/linux/seqlock.h | 19 +++++++++++++++---- kernel/time/sched_clock.c | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index cf87a24..7664f68 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -206,14 +206,26 @@ static inline int read_seqcount_retry(const seqcount_t *s, unsigned start) } + +static inline void write_seqcount_begin_no_lockdep(seqcount_t *s) +{ + s->sequence++; + smp_wmb(); +} + +static inline void write_seqcount_end_no_lockdep(seqcount_t *s) +{ + smp_wmb(); + s->sequence++; +} + /* * Sequence counter only version assumes that callers are using their * own mutexing. */ static inline void write_seqcount_begin_nested(seqcount_t *s, int subclass) { - s->sequence++; - smp_wmb(); + write_seqcount_begin_no_lockdep(s); seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_); } @@ -225,8 +237,7 @@ static inline void write_seqcount_begin(seqcount_t *s) static inline void write_seqcount_end(seqcount_t *s) { seqcount_release(&s->dep_map, 1, _RET_IP_); - smp_wmb(); - s->sequence++; + write_seqcount_end_no_lockdep(s); } /** diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 68b7993..13561a0 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -74,7 +74,7 @@ unsigned long long notrace sched_clock(void) return cd.epoch_ns; do { - seq = read_seqcount_begin(&cd.seq); + seq = read_seqcount_begin_no_lockdep(&cd.seq); epoch_cyc = cd.epoch_cyc; epoch_ns = cd.epoch_ns; } while (read_seqcount_retry(&cd.seq, seq)); @@ -99,10 +99,10 @@ static void notrace update_sched_clock(void) cd.mult, cd.shift); raw_local_irq_save(flags); - write_seqcount_begin(&cd.seq); + write_seqcount_begin_no_lockdep(&cd.seq); cd.epoch_ns = ns; cd.epoch_cyc = cyc; - write_seqcount_end(&cd.seq); + write_seqcount_end_no_lockdep(&cd.seq); raw_local_irq_restore(flags); } -- 1.8.3.2
WARNING: multiple messages have this Message-ID (diff)
From: john.stultz@linaro.org (John Stultz) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] sched_clock: Disable seqlock lockdep usage in sched_clock Date: Thu, 2 Jan 2014 13:54:46 -0800 [thread overview] Message-ID: <1388699686-4834-1-git-send-email-john.stultz@linaro.org> (raw) In-Reply-To: <52C5DB5B.9050604@linaro.org> Unforunately the seqlock lockdep enablmenet can't be used in sched_clock, since the lockdep infrastructure eventually calls into sched_clock, which causes a deadlock. Thus, this patch adds _no_lockdep() seqlock methods for the writer side, and changes all generic sched_clock usage to use the _no_lockdep methods. This solves the issue I was able to reproduce, but it would be good to get Krzysztof to confirm it solves his problem. Cc: Krzysztof Ha?asa <khalasa@piap.pl> Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> Cc: Willy Tarreau <w@1wt.eu> Cc: Ingo Molnar <mingo@kernel.org>, Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-arm-kernel at lists.infradead.org Reported-by: Krzysztof Ha?asa <khalasa@piap.pl> Signed-off-by: John Stultz <john.stultz@linaro.org> --- include/linux/seqlock.h | 19 +++++++++++++++---- kernel/time/sched_clock.c | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index cf87a24..7664f68 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -206,14 +206,26 @@ static inline int read_seqcount_retry(const seqcount_t *s, unsigned start) } + +static inline void write_seqcount_begin_no_lockdep(seqcount_t *s) +{ + s->sequence++; + smp_wmb(); +} + +static inline void write_seqcount_end_no_lockdep(seqcount_t *s) +{ + smp_wmb(); + s->sequence++; +} + /* * Sequence counter only version assumes that callers are using their * own mutexing. */ static inline void write_seqcount_begin_nested(seqcount_t *s, int subclass) { - s->sequence++; - smp_wmb(); + write_seqcount_begin_no_lockdep(s); seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_); } @@ -225,8 +237,7 @@ static inline void write_seqcount_begin(seqcount_t *s) static inline void write_seqcount_end(seqcount_t *s) { seqcount_release(&s->dep_map, 1, _RET_IP_); - smp_wmb(); - s->sequence++; + write_seqcount_end_no_lockdep(s); } /** diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 68b7993..13561a0 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -74,7 +74,7 @@ unsigned long long notrace sched_clock(void) return cd.epoch_ns; do { - seq = read_seqcount_begin(&cd.seq); + seq = read_seqcount_begin_no_lockdep(&cd.seq); epoch_cyc = cd.epoch_cyc; epoch_ns = cd.epoch_ns; } while (read_seqcount_retry(&cd.seq, seq)); @@ -99,10 +99,10 @@ static void notrace update_sched_clock(void) cd.mult, cd.shift); raw_local_irq_save(flags); - write_seqcount_begin(&cd.seq); + write_seqcount_begin_no_lockdep(&cd.seq); cd.epoch_ns = ns; cd.epoch_cyc = cyc; - write_seqcount_end(&cd.seq); + write_seqcount_end_no_lockdep(&cd.seq); raw_local_irq_restore(flags); } -- 1.8.3.2
next prev parent reply other threads:[~2014-01-02 21:55 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-31 10:37 v3.13-rc6+ regression (ARM board) Krzysztof Hałasa 2013-12-31 10:37 ` Krzysztof Hałasa 2013-12-31 10:45 ` Willy Tarreau 2013-12-31 10:45 ` Willy Tarreau 2014-01-02 10:02 ` Krzysztof Hałasa 2014-01-02 10:02 ` Krzysztof Hałasa 2014-01-02 10:14 ` Uwe Kleine-König 2014-01-02 10:14 ` Uwe Kleine-König 2014-01-02 12:07 ` Krzysztof Hałasa 2014-01-02 12:07 ` Krzysztof Hałasa 2014-01-02 19:38 ` Linus Torvalds 2014-01-02 19:38 ` Linus Torvalds 2014-01-02 20:03 ` John Stultz 2014-01-02 20:03 ` John Stultz 2014-01-02 20:30 ` John Stultz 2014-01-02 20:30 ` John Stultz 2014-01-02 20:42 ` Stephen Boyd 2014-01-02 20:42 ` Stephen Boyd 2014-01-02 20:52 ` John Stultz 2014-01-02 20:52 ` John Stultz 2014-01-02 20:43 ` Linus Torvalds 2014-01-02 20:43 ` Linus Torvalds 2014-01-02 21:34 ` John Stultz 2014-01-02 21:34 ` John Stultz 2014-01-02 21:54 ` John Stultz [this message] 2014-01-02 21:54 ` [PATCH] sched_clock: Disable seqlock lockdep usage in sched_clock John Stultz 2014-01-02 22:15 ` Linus Torvalds 2014-01-02 22:15 ` Linus Torvalds 2014-01-02 22:21 ` John Stultz 2014-01-02 22:21 ` John Stultz 2014-01-02 23:11 ` [PATCH 1/2] seqlock: Use raw_ prefix instead of _no_lockdep John Stultz 2014-01-02 23:11 ` John Stultz 2014-01-02 23:11 ` [PATCH 2/2] sched_clock: Disable seqlock lockdep usage in sched_clock John Stultz 2014-01-02 23:11 ` John Stultz 2014-01-03 0:46 ` Stephen Boyd 2014-01-03 0:46 ` Stephen Boyd 2014-01-03 6:05 ` Krzysztof Hałasa 2014-01-03 6:05 ` Krzysztof Hałasa 2014-01-12 18:42 ` [tip:core/urgent] sched_clock: Disable seqlock lockdep usage in sched_clock() tip-bot for John Stultz 2014-01-14 19:18 ` John Stultz 2014-01-15 6:38 ` Ingo Molnar 2014-01-03 0:46 ` [PATCH 1/2] seqlock: Use raw_ prefix instead of _no_lockdep Stephen Boyd 2014-01-03 0:46 ` Stephen Boyd 2014-01-03 0:50 ` Linus Torvalds 2014-01-03 0:50 ` Linus Torvalds 2014-01-04 0:28 ` John Stultz 2014-01-04 0:28 ` John Stultz 2014-01-06 10:10 ` Peter Zijlstra 2014-01-06 10:10 ` Peter Zijlstra 2014-01-12 18:42 ` [tip:core/urgent] " tip-bot for John Stultz 2014-01-03 6:01 ` v3.13-rc6+ regression (ARM board) Krzysztof Hałasa 2014-01-03 6:01 ` Krzysztof Hałasa
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=1388699686-4834-1-git-send-email-john.stultz@linaro.org \ --to=john.stultz@linaro.org \ --cc=khalasa@piap.pl \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@kernel.org \ --cc=peterz@infradead.org \ --cc=sboyd@codeaurora.org \ --cc=torvalds@linux-foundation.org \ --cc=u.kleine-koenig@pengutronix.de \ --cc=w@1wt.eu \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.