From: Peter Zijlstra <peterz@infradead.org>
To: Pavan Kondeti <pkondeti@codeaurora.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] sched: Optimize pick_next_task for idle_sched_class too
Date: Thu, 23 Feb 2017 18:54:38 +0100 [thread overview]
Message-ID: <20170223175438.GX6536@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20170223174505.GI6515@twins.programming.kicks-ass.net>
On Thu, Feb 23, 2017 at 06:45:05PM +0100, Peter Zijlstra wrote:
> Hurm.. maybe we should do what Steve initially suggested. The
> alternative is link order trickery, and I'm not sure we want to do that.
That is, given:
kernel/sched/Makefile: obj-y += idle_task.o fair.o rt.o deadline.o stop_task.o
results in:
readelf -s defconfig-build/vmlinux | awk '/sched_class/ {print $2 " " $8}' | sort -n
00000000602c93c0 idle_sched_class
00000000602c9480 fair_sched_class
00000000602c9580 rt_sched_class
00000000602c96c0 dl_sched_class
00000000602c97c0 stop_sched_class
we can do this, but yuck!
---
kernel/sched/core.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8f972df76eb2..eebe6729ceb7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3285,10 +3285,16 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
struct task_struct *p;
/*
- * Optimization: we know that if all tasks are in
- * the fair class we can call that function directly:
+ * Optimization: we know that if all tasks are in the fair class we can
+ * call that function directly, but only if the @prev task wasn't of a
+ * higher scheduling class, because otherwise those loose the
+ * opportinity to pull in more work from other CPUs.
+ *
+ * Depends on link order in kernel/sched/Makefile.
*/
- if (likely(rq->nr_running == rq->cfs.h_nr_running)) {
+ if (likely(rq->nr_running == rq->cfs.h_nr_running &&
+ prev->sched_class <= &fair_sched_class)) {
+
p = fair_sched_class.pick_next_task(rq, prev, rf);
if (unlikely(p == RETRY_TASK))
goto again;
next prev parent reply other threads:[~2017-02-23 17:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 15:17 [PATCH] sched: Optimize pick_next_task for idle_sched_class too Steven Rostedt
2017-01-19 17:44 ` Peter Zijlstra
2017-01-20 16:14 ` Steven Rostedt
2017-01-20 16:16 ` Steven Rostedt
2017-01-20 16:52 ` Peter Zijlstra
2017-01-30 11:54 ` [tip:sched/core] sched/core: Optimize pick_next_task() for idle_sched_class tip-bot for Peter Zijlstra
2017-02-23 10:34 ` [PATCH] sched: Optimize pick_next_task for idle_sched_class too Pavan Kondeti
2017-02-23 13:54 ` Peter Zijlstra
2017-02-23 15:15 ` Pavan Kondeti
2017-02-23 15:25 ` Peter Zijlstra
2017-02-23 16:37 ` Peter Zijlstra
2017-02-23 17:29 ` Pavan Kondeti
2017-02-23 17:45 ` Peter Zijlstra
2017-02-23 17:54 ` Peter Zijlstra [this message]
2017-02-27 17:54 ` Steven Rostedt
2017-03-01 15:53 ` Steven Rostedt
2017-03-01 16:03 ` Peter Zijlstra
2017-03-01 16:19 ` Steven Rostedt
2017-03-01 16:22 ` 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=20170223175438.GX6536@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pkondeti@codeaurora.org \
--cc=rostedt@goodmis.org \
/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