From: Frederic Weisbecker <fweisbec@gmail.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>
Subject: [PATCH 2/7] rcu: Fix early call to rcu_enter_nohz() on tick stopping
Date: Mon, 26 Sep 2011 12:19:07 +0200 [thread overview]
Message-ID: <1317032352-25571-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1317032352-25571-1-git-send-email-fweisbec@gmail.com>
In tick_nohz_stop_sched_tick(), we enter RCU extended quiescent
state right before reprogramming the next timer.
However when we reprogram it, we may raise the hrtimer softirq,
thus entering the scheduler to wake up the softirq thread and
iterate over the scheduler domains under RCU when we search the dest
CPU for the task.
We need to be outside an RCU extended quiescent state to achieve
this otherwise it's an illegal use of RCU:
WARNING: at include/linux/rcupdate.h:248 select_task_rq_fair+0xc9b/0xcd0()
Hardware name: AMD690VM-FMH
Modules linked in:
Pid: 0, comm: swapper Tainted: G W 3.0.0+ #56
Call Trace:
[<ffffffff8105cc3f>] warn_slowpath_common+0x7f/0xc0
[<ffffffff8105cc9a>] warn_slowpath_null+0x1a/0x20
[<ffffffff8105239b>] select_task_rq_fair+0xc9b/0xcd0
[<ffffffff812f2b64>] ? do_raw_spin_lock+0x54/0x160
[<ffffffff81058ee3>] try_to_wake_up+0xd3/0x300
[<ffffffff81090758>] ? ktime_get+0x68/0xf0
[<ffffffff81059165>] wake_up_process+0x15/0x20
[<ffffffff81065135>] raise_softirq_irqoff+0x65/0x110
[<ffffffff8108a2d5>] __hrtimer_start_range_ns+0x415/0x5a0
[<ffffffff8108a478>] hrtimer_start+0x18/0x20
[<ffffffff810980e0>] tick_nohz_stop_sched_tick+0x2b0/0x3c0
[<ffffffff8100a9c1>] cpu_idle+0x81/0x120
[<ffffffff817e720f>] rest_init+0xef/0x170
[<ffffffff817e7172>] ? rest_init+0x52/0x170
[<ffffffff81ed6cb7>] start_kernel+0x3cb/0x3d6
[<ffffffff81ed6346>] x86_64_start_reservations+0x131/0x135
[<ffffffff81ed644d>] x86_64_start_kernel+0x103/0x112
Fix this by calling rcu_enter_nohz() only once everything is done
to stop the tick.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
---
kernel/time/tick-sched.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index eb98e55..9416700 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -246,19 +246,13 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
}
EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
-/**
- * tick_nohz_stop_sched_tick - stop the idle tick from the idle task
- *
- * When the next event is more than a tick into the future, stop the idle tick
- * Called either from the idle loop or from irq_exit() when an idle period was
- * just interrupted by an interrupt which did not cause a reschedule.
- */
-void tick_nohz_stop_sched_tick(int inidle)
+static bool __tick_nohz_stop_sched_tick(int inidle)
{
unsigned long seq, last_jiffies, next_jiffies, delta_jiffies, flags;
struct tick_sched *ts;
ktime_t last_update, expires, now;
struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
+ bool stopped = false;
u64 time_delta;
int cpu;
@@ -405,7 +399,7 @@ void tick_nohz_stop_sched_tick(int inidle)
ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
ts->tick_stopped = 1;
ts->idle_jiffies = last_jiffies;
- rcu_enter_nohz();
+ stopped = true;
}
ts->idle_sleeps++;
@@ -445,6 +439,21 @@ out:
ts->sleep_length = ktime_sub(dev->next_event, now);
end:
local_irq_restore(flags);
+
+ return stopped;
+}
+
+/**
+ * tick_nohz_stop_sched_tick - stop the idle tick from the idle task
+ *
+ * When the next event is more than a tick into the future, stop the idle tick
+ * Called either from the idle loop or from irq_exit() when an idle period was
+ * just interrupted by an interrupt which did not cause a reschedule.
+ */
+void tick_nohz_stop_sched_tick(int inidle)
+{
+ if (__tick_nohz_stop_sched_tick(inidle))
+ rcu_enter_nohz();
}
/**
--
1.7.5.4
next prev parent reply other threads:[~2011-09-26 10:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 10:19 [PATCH 0/7 v4] rcu: Fix some rcu uses in extended quiescent state Frederic Weisbecker
2011-09-26 10:19 ` [PATCH 1/7] rcu: Fix preempt-unsafe debug check of rcu " Frederic Weisbecker
2011-09-26 22:04 ` Pavel Ivanov
2011-09-27 11:50 ` Frederic Weisbecker
2011-09-27 15:16 ` Pavel Ivanov
2011-09-27 16:01 ` Paul E. McKenney
2011-09-27 21:44 ` Frederic Weisbecker
2011-09-28 3:17 ` Yong Zhang
2011-09-28 12:44 ` Frederic Weisbecker
2011-09-28 3:52 ` Pavel Ivanov
2011-09-28 12:46 ` Frederic Weisbecker
2011-09-26 10:19 ` Frederic Weisbecker [this message]
2011-09-26 10:19 ` [PATCH 3/7] nohz: Separate out irq exit and idle loop dyntick logic Frederic Weisbecker
2011-09-26 10:19 ` [PATCH 4/7] nohz: Allow rcu extended quiescent state handling seperately from tick stop Frederic Weisbecker
2011-09-26 10:44 ` Peter Zijlstra
2011-09-26 16:02 ` Paul E. McKenney
2011-09-26 16:06 ` Peter Zijlstra
2011-09-26 16:32 ` Paul E. McKenney
2011-09-26 17:06 ` Frederic Weisbecker
2011-09-26 10:19 ` [PATCH 5/7] x86: Enter rcu extended qs after idle notifier call Frederic Weisbecker
2011-09-26 10:19 ` [PATCH 6/7] x86: Call idle notifier after irq_enter() Frederic Weisbecker
2011-09-26 10:19 ` [PATCH 7/7] rcu: Fix early call to rcu_irq_exit() Frederic Weisbecker
2011-09-26 18:26 ` [PATCH 0/7 v4] rcu: Fix some rcu uses in extended quiescent state 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=1317032352-25571-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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
Powered by JetHome