From: Juri Lelli <juri.lelli@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: luca abeni <luca.abeni@unitn.it>,
linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, vincent.guittot@linaro.org,
wanpeng.li@hotmail.com
Subject: Re: [PATCH 1/2] sched/deadline: add per rq tracking of admitted bandwidth
Date: Thu, 11 Feb 2016 17:10:12 +0000 [thread overview]
Message-ID: <20160211171012.GS11415@e106622-lin> (raw)
In-Reply-To: <20160211092546.5b607147@gandalf.local.home>
On 11/02/16 09:25, Steven Rostedt wrote:
> On Thu, 11 Feb 2016 14:05:45 +0100
> luca abeni <luca.abeni@unitn.it> wrote:
>
>
> > Well, I never used the rq utilization to re-build the root_domain
> > utilization (and I never played with root domains too much... :)...
> > So, I do not really know. Maybe the code should do:
> > raw_spin_lock(&rq->lock);
> > raw_spin_lock(&cpu_rq(cpu)->lock);
>
> Of course you want to use double_rq_lock() here instead.
>
Right. Is something like this completely out of question/broken?
I slighly tested it with Steve's test and I don't see the warning
anymore (sched_debug looks good as well); but my confidence is still
pretty low. :(
--->8---
>From 9713e12bc682ca364e62f9d69bcd44598c50a8a9 Mon Sep 17 00:00:00 2001
From: Juri Lelli <juri.lelli@arm.com>
Date: Thu, 11 Feb 2016 16:55:49 +0000
Subject: [PATCH] fixup! sched/deadline: add per rq tracking of admitted
bandwidth
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
include/linux/init_task.h | 1 +
include/linux/sched.h | 1 +
kernel/sched/core.c | 5 ++++-
kernel/sched/deadline.c | 26 +++++++++++++++++++++++++-
4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index f2cb8d4..c582f9d 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -199,6 +199,7 @@ extern struct task_group root_task_group;
.policy = SCHED_NORMAL, \
.cpus_allowed = CPU_MASK_ALL, \
.nr_cpus_allowed= NR_CPUS, \
+ .fallback_cpu = -1, \
.mm = NULL, \
.active_mm = &init_mm, \
.restart_block = { \
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a10494a..a6fc95c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1401,6 +1401,7 @@ struct task_struct {
struct task_struct *last_wakee;
int wake_cpu;
+ int fallback_cpu;
#endif
int on_rq;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7fb9246..4e4bc41 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1442,7 +1442,8 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
continue;
if (!cpu_active(dest_cpu))
continue;
- if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p)))
+ if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) {
+ p->fallback_cpu = dest_cpu;
return dest_cpu;
}
}
@@ -1490,6 +1491,7 @@ out:
}
}
+ p->fallback_cpu = dest_cpu;
return dest_cpu;
}
@@ -1954,6 +1956,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
if (task_cpu(p) != cpu) {
wake_flags |= WF_MIGRATED;
set_task_cpu(p, cpu);
+ p->fallback_cpu = -1;
}
#endif /* CONFIG_SMP */
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 6368f43..1eccecf 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1043,6 +1043,21 @@ static void yield_task_dl(struct rq *rq)
#ifdef CONFIG_SMP
+static void swap_task_ac_bw(struct task_struct *p,
+ struct rq *from,
+ struct rq *to)
+{
+ unsigned long flags;
+
+ lockdep_assert_held(&p->pi_lock);
+ local_irq_save(flags);
+ double_rq_lock(from, to);
+ __dl_sub_ac(from, p->dl.dl_bw);
+ __dl_add_ac(to, p->dl.dl_bw);
+ double_rq_unlock(from, to);
+ local_irq_restore(flags);
+}
+
static int find_later_rq(struct task_struct *task);
static int
@@ -1077,8 +1092,10 @@ select_task_rq_dl(struct task_struct *p, int cpu, int sd_flag, int flags)
if (target != -1 &&
(dl_time_before(p->dl.deadline,
cpu_rq(target)->dl.earliest_dl.curr) ||
- (cpu_rq(target)->dl.dl_nr_running == 0)))
+ (cpu_rq(target)->dl.dl_nr_running == 0))) {
cpu = target;
+ swap_task_ac_bw(p, rq, cpu_rq(target));
+ }
}
rcu_read_unlock();
@@ -1807,6 +1824,12 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p,
switched_to_dl(rq, p);
}
+static void migrate_task_rq_dl(struct task_struct *p)
+{
+ if (p->fallback_cpu != -1)
+ swap_task_ac_bw(p, task_rq(p), cpu_rq(p->fallback_cpu));
+}
+
const struct sched_class dl_sched_class = {
.next = &rt_sched_class,
.enqueue_task = enqueue_task_dl,
@@ -1820,6 +1843,7 @@ const struct sched_class dl_sched_class = {
#ifdef CONFIG_SMP
.select_task_rq = select_task_rq_dl,
+ .migrate_task_rq = migrate_task_rq_dl,
.set_cpus_allowed = set_cpus_allowed_dl,
.rq_online = rq_online_dl,
.rq_offline = rq_offline_dl,
--
2.7.0
next prev parent reply other threads:[~2016-02-11 17:09 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-08 12:45 [PATCH 0/2] sched/deadline: fix cpusets bandwidth accounting Juri Lelli
2016-02-08 12:45 ` [PATCH 1/2] sched/deadline: add per rq tracking of admitted bandwidth Juri Lelli
2016-02-10 11:32 ` Juri Lelli
2016-02-10 11:43 ` luca abeni
2016-02-10 11:58 ` Juri Lelli
2016-02-19 13:43 ` luca abeni
2016-02-19 14:20 ` Steven Rostedt
2016-02-19 14:53 ` luca abeni
2016-02-19 14:57 ` Steven Rostedt
2016-02-22 11:03 ` luca abeni
2016-02-22 10:57 ` [PATCH 0/3] cleanup " Luca Abeni
2016-02-22 10:57 ` [PATCH 1/4] Move some calls to __dl_{sub,add}_ac() from core.c to deadline.c Luca Abeni
2016-02-22 10:57 ` [PATCH 2/4] Move the remaining __dl_{sub,add}_ac() calls " Luca Abeni
2016-02-22 10:57 ` [PATCH 3/4] Remove dl_new Luca Abeni
2016-02-23 15:42 ` Peter Zijlstra
2016-02-24 13:53 ` luca abeni
2016-02-25 9:46 ` Juri Lelli
2016-03-03 9:03 ` luca abeni
2016-03-03 9:28 ` Juri Lelli
2016-03-03 14:23 ` Steven Rostedt
2016-03-03 14:31 ` luca abeni
2016-03-03 16:12 ` Juri Lelli
2016-02-10 12:48 ` [PATCH 1/2] sched/deadline: add per rq tracking of admitted bandwidth luca abeni
2016-02-10 13:42 ` Juri Lelli
2016-02-23 15:48 ` Peter Zijlstra
2016-02-23 15:51 ` Juri Lelli
2016-02-10 14:37 ` Steven Rostedt
2016-02-10 16:27 ` Juri Lelli
2016-02-11 12:12 ` Juri Lelli
2016-02-11 12:22 ` luca abeni
2016-02-11 12:27 ` Juri Lelli
2016-02-11 12:40 ` luca abeni
2016-02-11 12:49 ` Juri Lelli
2016-02-11 13:05 ` luca abeni
2016-02-11 14:25 ` Steven Rostedt
2016-02-11 17:10 ` Juri Lelli [this message]
2016-02-12 17:05 ` Peter Zijlstra
2016-02-12 17:19 ` Juri Lelli
2016-02-24 19:17 ` Peter Zijlstra
2016-02-24 21:46 ` luca abeni
2016-02-25 7:53 ` Peter Zijlstra
2016-02-25 10:07 ` Juri Lelli
2016-02-25 10:20 ` Peter Zijlstra
2016-03-24 9:20 ` Peter Zijlstra
2016-02-11 21:48 ` Luca Abeni
2016-02-08 12:45 ` [PATCH 2/2] sched/deadline: rq_{online,offline}_dl for root_domain changes Juri Lelli
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=20160211171012.GS11415@e106622-lin \
--to=juri.lelli@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@unitn.it \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=wanpeng.li@hotmail.com \
/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;
as well as URLs for NNTP newsgroup(s).