From: Fabio Checconi <fchecconi@gmail.com>
To: mingo@elte.hu, a.p.zijlstra@chello.nl
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] Fix hrtick handling
Date: Mon, 15 Jun 2009 21:05:28 +0200 [thread overview]
Message-ID: <20090615190528.GL21741@gandalf.sssup.it> (raw)
In-Reply-To: <cover.1245092261.git.fabio@helm.retis>
The current hrtick implementation can end up asking to the hrtimer code
to wake up ksoftirqd while holding rq->lock, causing a spinlock recursion.
This patch uses __hrtimer_start_range_ns() to disable the wakeup in the
reprogramming path.
Signed-off-by: Fabio Checconi <fabio@gandalf.sssup.it>
---
kernel/sched.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 873b252..b8d432b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1090,6 +1090,19 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer)
}
#ifdef CONFIG_SMP
+static void hrtick_restart(struct hrtimer *timer)
+{
+ ktime_t hard, soft;
+ unsigned long delta;
+
+ soft = hrtimer_get_softexpires(timer);
+ hard = hrtimer_get_expires(timer);
+ delta = ktime_to_ns(ktime_sub(hard, soft));
+
+ __hrtimer_start_range_ns(timer, soft, delta,
+ HRTIMER_MODE_ABS_PINNED, 0);
+}
+
/*
* called from hardirq (IPI) context
*/
@@ -1098,7 +1111,7 @@ static void __hrtick_start(void *arg)
struct rq *rq = arg;
spin_lock(&rq->lock);
- hrtimer_restart(&rq->hrtick_timer);
+ hrtick_restart(&rq->hrtick_timer);
rq->hrtick_csd_pending = 0;
spin_unlock(&rq->lock);
}
@@ -1116,7 +1129,7 @@ static void hrtick_start(struct rq *rq, u64 delay)
hrtimer_set_expires(timer, time);
if (rq == this_rq()) {
- hrtimer_restart(timer);
+ hrtick_restart(timer);
} else if (!rq->hrtick_csd_pending) {
__smp_call_function_single(cpu_of(rq), &rq->hrtick_csd, 0);
rq->hrtick_csd_pending = 1;
@@ -1173,7 +1186,8 @@ static void init_rq_hrtick(struct rq *rq)
rq->hrtick_csd.info = rq;
#endif
- hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL_PINNED);
rq->hrtick_timer.function = hrtick;
}
#else /* CONFIG_SCHED_HRTICK */
--
1.6.2.2
next prev parent reply other threads:[~2009-06-15 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-15 18:55 [RFC][PATCH 0/8] Use EDF to throttle RT task groups Fabio Checconi
2009-06-15 18:56 ` [PATCH 1/8] Fix rt_rq->pushable_tasks initialization in init_rt_rq() Fabio Checconi
2009-07-09 10:43 ` Peter Zijlstra
2009-07-10 10:41 ` [tip:sched/urgent] sched: " tip-bot for Fabio Checconi
2009-06-15 19:05 ` Fabio Checconi [this message]
2009-07-09 10:42 ` [PATCH 2/8] Fix hrtick handling Peter Zijlstra
2009-06-15 19:06 ` [PATCH 3/8] Replace struct prio_array with an RB tree Fabio Checconi
2009-06-15 19:06 ` [PATCH 4/8] Remove the balancing logic Fabio Checconi
2009-06-15 19:08 ` [PATCH 5/8] Use EDF to throttle RT tasks hierarchically Fabio Checconi
2009-06-15 19:08 ` [PATCH 6/8] Modify the curr/next priority tracking Fabio Checconi
2009-06-15 19:09 ` [PATCH 7/8] Reprogram timers only when necessary Fabio Checconi
2009-06-15 19:09 ` [PATCH 8/8] Use hrtick when available Fabio Checconi
2009-07-09 10:36 ` [RFC][PATCH 0/8] Use EDF to throttle RT task groups Peter Zijlstra
2009-07-09 13:51 ` Fabio Checconi
2009-07-15 7:50 ` Peter Zijlstra
2009-07-15 12:08 ` Fabio Checconi
2009-07-15 14:25 ` 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=20090615190528.GL21741@gandalf.sssup.it \
--to=fchecconi@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
all inboxes | Powered by JetHome®