From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: efault@gmx.de, linux-kernel@vger.kernel.org, tglx@linutronix.de,
torvalds@linux-foundation.org, paulmck@linux.vnet.ibm.com,
mingo@kernel.org, hpa@zytor.com, peterz@infradead.org
Subject: [tip:sched/urgent] sched/clock: Fix clear_sched_clock_stable() preempt wobbly
Date: Thu, 23 Mar 2017 02:10:47 -0700 [thread overview]
Message-ID: <tip-71fdb70eb48784c1f28cdf2e67c4c587dd7f2594@git.kernel.org> (raw)
In-Reply-To: <20170313124621.GA3328@twins.programming.kicks-ass.net>
Commit-ID: 71fdb70eb48784c1f28cdf2e67c4c587dd7f2594
Gitweb: http://git.kernel.org/tip/71fdb70eb48784c1f28cdf2e67c4c587dd7f2594
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 13 Mar 2017 13:46:21 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 23 Mar 2017 07:31:48 +0100
sched/clock: Fix clear_sched_clock_stable() preempt wobbly
Paul reported a problems with clear_sched_clock_stable(). Since we run
all of __clear_sched_clock_stable() from workqueue context, there's a
preempt problem.
Solve it by only running the static_key_disable() from workqueue.
Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: fweisbec@gmail.com
Link: http://lkml.kernel.org/r/20170313124621.GA3328@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/clock.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index a08795e..fec0f58 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -141,7 +141,14 @@ static void __set_sched_clock_stable(void)
tick_dep_clear(TICK_DEP_BIT_CLOCK_UNSTABLE);
}
-static void __clear_sched_clock_stable(struct work_struct *work)
+static void __sched_clock_work(struct work_struct *work)
+{
+ static_branch_disable(&__sched_clock_stable);
+}
+
+static DECLARE_WORK(sched_clock_work, __sched_clock_work);
+
+static void __clear_sched_clock_stable(void)
{
struct sched_clock_data *scd = this_scd();
@@ -160,11 +167,11 @@ static void __clear_sched_clock_stable(struct work_struct *work)
scd->tick_gtod, gtod_offset,
scd->tick_raw, raw_offset);
- static_branch_disable(&__sched_clock_stable);
tick_dep_set(TICK_DEP_BIT_CLOCK_UNSTABLE);
-}
-static DECLARE_WORK(sched_clock_work, __clear_sched_clock_stable);
+ if (sched_clock_stable())
+ schedule_work(&sched_clock_work);
+}
void clear_sched_clock_stable(void)
{
@@ -173,7 +180,7 @@ void clear_sched_clock_stable(void)
smp_mb(); /* matches sched_clock_init_late() */
if (sched_clock_running == 2)
- schedule_work(&sched_clock_work);
+ __clear_sched_clock_stable();
}
void sched_clock_init_late(void)
next prev parent reply other threads:[~2017-03-23 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 21:53 [PATCH] clock: Fix smp_processor_id() in preemptible bug Paul E. McKenney
2017-03-09 15:24 ` Peter Zijlstra
2017-03-09 15:31 ` Paul E. McKenney
2017-03-09 18:37 ` Paul E. McKenney
2017-03-10 17:27 ` Paul E. McKenney
2017-03-13 12:46 ` Peter Zijlstra
2017-03-13 15:55 ` Paul E. McKenney
2017-03-14 16:24 ` Paul E. McKenney
2017-03-15 22:58 ` Paul E. McKenney
2017-03-16 15:53 ` Peter Zijlstra
2017-03-16 16:57 ` Paul E. McKenney
2017-03-16 21:00 ` Paul E. McKenney
2017-03-16 21:06 ` Paul E. McKenney
2017-03-23 9:10 ` tip-bot for Peter Zijlstra [this message]
2017-03-23 16:52 ` [tip:sched/urgent] sched/clock: Fix clear_sched_clock_stable() preempt wobbly Paul E. McKenney
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=tip-71fdb70eb48784c1f28cdf2e67c4c587dd7f2594@git.kernel.org \
--to=tipbot@zytor.com \
--cc=efault@gmx.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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 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.