From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>, "Daniel K." <dk@uw.no>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 07/10] sched: rt: fix SMP bandwidth balancing for throttled groups
Date: Thu, 19 Jun 2008 14:22:25 +0200 [thread overview]
Message-ID: <20080619123314.178592128@chello.nl> (raw)
In-Reply-To: <20080619122218.971447669@chello.nl>
[-- Attachment #1: sched-rt-bw-balance-fix.patch --]
[-- Type: text/plain, Size: 2792 bytes --]
We didn't balance the runtime when throttled, this can cause large wakeup
latencies. Suppose a task is migrated to another cpu right before the group
quota runs out - its likely that the previuos cpu had a large amount of the
group runtime, whereas the new cpu would be almost depleted (due to it being
handed the other cpu).
Now we exceed the runtime and get throttled - the period rollover tick will
subtract the cpu quota from the runtime and check if we're below quota. However
with this cpu having a very small portion of the runtime it will not refresh
as fast as it should.
Therefore, also rebalance the runtime when we're throttled.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/sched_rt.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
Index: linux-2.6/kernel/sched_rt.c
===================================================================
--- linux-2.6.orig/kernel/sched_rt.c
+++ linux-2.6/kernel/sched_rt.c
@@ -222,6 +222,28 @@ static inline struct rt_bandwidth *sched
#endif
+#ifdef CONFIG_SMP
+static int do_balance_runtime(struct rt_rq *rt_rq);
+
+static int balance_runtime(struct rt_rq *rt_rq)
+{
+ int more = 0;
+
+ if (rt_rq->rt_time > rt_rq->rt_runtime) {
+ spin_unlock(&rt_rq->rt_runtime_lock);
+ more = do_balance_runtime(rt_rq);
+ spin_lock(&rt_rq->rt_runtime_lock);
+ }
+
+ return more;
+}
+#else
+static inline int balance_runtime(struct rt_rq *rt_rq)
+{
+ return 0;
+}
+#endif
+
static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
{
int i, idle = 1;
@@ -241,6 +263,8 @@ static int do_sched_rt_period_timer(stru
u64 runtime;
spin_lock(&rt_rq->rt_runtime_lock);
+ if (rt_rq->rt_throttled)
+ balance_runtime(rt_rq);
runtime = rt_rq->rt_runtime;
rt_rq->rt_time -= min(rt_rq->rt_time, overrun*runtime);
if (rt_rq->rt_throttled && rt_rq->rt_time < runtime) {
@@ -261,7 +285,7 @@ static int do_sched_rt_period_timer(stru
}
#ifdef CONFIG_SMP
-static int balance_runtime(struct rt_rq *rt_rq)
+static int do_balance_runtime(struct rt_rq *rt_rq)
{
struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
@@ -422,17 +446,10 @@ static int sched_rt_runtime_exceeded(str
if (sched_rt_runtime(rt_rq) >= sched_rt_period(rt_rq))
return 0;
-#ifdef CONFIG_SMP
- if (rt_rq->rt_time > runtime) {
- spin_unlock(&rt_rq->rt_runtime_lock);
- balance_runtime(rt_rq);
- spin_lock(&rt_rq->rt_runtime_lock);
-
- runtime = sched_rt_runtime(rt_rq);
- if (runtime == RUNTIME_INF)
- return 0;
- }
-#endif
+ balance_runtime(rt_rq);
+ runtime = sched_rt_runtime(rt_rq);
+ if (runtime == RUNTIME_INF)
+ return 0;
if (rt_rq->rt_time > runtime) {
rt_rq->rt_throttled = 1;
--
next prev parent reply other threads:[~2008-06-19 12:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-19 12:22 [PATCH 00/10] sched: rt bandwidth/group fixes Peter Zijlstra
2008-06-19 12:22 ` [PATCH 01/10] sched: NULL pointer dereference while setting sched_rt_period_us Peter Zijlstra
2008-06-19 12:22 ` [PATCH 02/10] sched: rt-group: fix hierarchy Peter Zijlstra
2008-06-19 12:22 ` [PATCH 03/10] sched: rt-group: heirarchy aware throttle Peter Zijlstra
2008-06-19 12:22 ` [PATCH 04/10] sched: rt-group: fix RR buglet Peter Zijlstra
2008-06-19 12:22 ` [PATCH 05/10] sched: rt-bandwidth: fix cpu-hotplug interaction Peter Zijlstra
2008-06-19 12:22 ` [PATCH 06/10] sched: debug: add some rt debug output Peter Zijlstra
2008-06-19 12:22 ` Peter Zijlstra [this message]
2008-06-19 12:22 ` [PATCH 08/10] sched: rt: move some code around Peter Zijlstra
2008-06-19 12:22 ` [PATCH 09/10] sched: rt: fix the bandwidth contraint computations Peter Zijlstra
2008-06-19 12:22 ` [PATCH 10/10] sched: rt: dont stop the period timer when there are tasks wanting to run Peter Zijlstra
2008-06-19 20:10 ` Daniel K.
2008-06-19 20:16 ` Peter Zijlstra
2008-06-20 9:06 ` Ingo Molnar
2008-06-20 8:47 ` [PATCH 00/10] sched: rt bandwidth/group fixes Ingo Molnar
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=20080619123314.178592128@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=dk@uw.no \
--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
Powered by JetHome