From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbbFAOOR (ORCPT ); Mon, 1 Jun 2015 10:14:17 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:52735 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753028AbbFAON0 (ORCPT ); Mon, 1 Jun 2015 10:13:26 -0400 Message-Id: <20150601140840.270836867@infradead.org> User-Agent: quilt/0.61-1 Date: Mon, 01 Jun 2015 15:58:25 +0200 From: Peter Zijlstra To: umgwanakikbuti@gmail.com, mingo@elte.hu Cc: ktkhai@parallels.com, rostedt@goodmis.org, juri.lelli@gmail.com, pang.xunlei@linaro.org, oleg@redhat.com, linux-kernel@vger.kernel.org, "Peter Zijlstra" Subject: [RFC][PATCH 7/7] sched,dl: Convert switched_{from,to}_dl() / prio_changed_dl() to balance callbacks References: <20150601135818.506080835@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-sched-post_schedule-5.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the direct {push,pull} balancing operations from switched_{from,to}_dl() / prio_changed_dl() and use the balance callback queue. Again, err on the side of too many reschedules; since too few is a hard bug while too many is just annoying. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/deadline.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -213,16 +213,23 @@ static inline bool need_pull_dl_task(str return dl_task(prev); } -static DEFINE_PER_CPU(struct callback_head, dl_balance_head); +static DEFINE_PER_CPU(struct callback_head, dl_push_head); +static DEFINE_PER_CPU(struct callback_head, dl_pull_head); static void push_dl_tasks(struct rq *); +static void pull_dl_task(struct rq *); static inline void queue_push_tasks(struct rq *rq) { if (!has_pushable_dl_tasks(rq)) return; - queue_balance_callback(rq, &per_cpu(dl_balance_head, rq->cpu), push_dl_tasks); + queue_balance_callback(rq, &per_cpu(dl_push_head, rq->cpu), push_dl_tasks); +} + +static inline void queue_pull_task(struct rq *rq) +{ + queue_balance_callback(rq, &per_cpu(dl_pull_head, rq->cpu), pull_dl_task); } static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq); @@ -1040,8 +1047,6 @@ static void check_preempt_equal_dl(struc resched_curr(rq); } -static void pull_dl_task(struct rq *this_rq); - #endif /* CONFIG_SMP */ /* @@ -1705,7 +1710,7 @@ static void switched_from_dl(struct rq * if (!task_on_rq_queued(p) || rq->dl.dl_nr_running) return; - pull_dl_task(rq); + queue_pull_task(rq); } /* @@ -1714,21 +1719,16 @@ static void switched_from_dl(struct rq * */ static void switched_to_dl(struct rq *rq, struct task_struct *p) { - int check_resched = 1; - if (task_on_rq_queued(p) && rq->curr != p) { #ifdef CONFIG_SMP - if (p->nr_cpus_allowed > 1 && rq->dl.overloaded && - push_dl_task(rq) && rq != task_rq(p)) - /* Only reschedule if pushing failed */ - check_resched = 0; -#endif /* CONFIG_SMP */ - if (check_resched) { - if (dl_task(rq->curr)) - check_preempt_curr_dl(rq, p, 0); - else - resched_curr(rq); - } + if (p->nr_cpus_allowed > 1 && rq->dl.overloaded) + queue_push_tasks(rq); +#else + if (dl_task(rq->curr)) + check_preempt_curr_dl(rq, p, 0); + else + resched_curr(rq); +#endif } } @@ -1748,15 +1748,14 @@ static void prio_changed_dl(struct rq *r * or lowering its prio, so... */ if (!rq->dl.overloaded) - pull_dl_task(rq); + queue_pull_task(rq); /* * If we now have a earlier deadline task than p, * then reschedule, provided p is still on this * runqueue. */ - if (dl_time_before(rq->dl.earliest_dl.curr, p->dl.deadline) && - rq->curr == p) + if (dl_time_before(rq->dl.earliest_dl.curr, p->dl.deadline)) resched_curr(rq); #else /*