From: Tim Chen <tim.c.chen@linux.intel.com>
To: Ingo Molnar <mingo@elte.hu>, Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Len Brown <len.brown@intel.com>
Subject: [PATCH] sched: Skip double execution of pick_next_task_fair
Date: Wed, 23 Apr 2014 15:31:57 -0700 [thread overview]
Message-ID: <1398292317.2970.63.camel@schen9-DESK> (raw)
The current code will call pick_next_task_fair a second time
in the slow path if we did not pull any task in our first try.
This is really unnecessary as we already know no task can
be pulled and it doubles the delay for the cpu to enter idle.
We instrumented some network workloads and that saw that
pick_next_task_fair is frequently called twice before a cpu enters idle.
The call to pick_next_task_fair can add
non trivial latency as it calls load_balance which runs find_busiest_group
on an hierarchy of sched domains spanning the cpus for a large system. For
some 4 socket systems, we saw almost 0.25 msec spent per call
of pick_next_task_fair before a cpu can be idled.
This patch skips pick_next_task_fair in the slow path if it
has already been invoked.
Tim
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
kernel/sched/core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1d1b87b..4053437 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2583,6 +2583,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev)
{
const struct sched_class *class = &fair_sched_class;
struct task_struct *p;
+ int skip_fair = 0;
/*
* Optimization: we know that if all tasks are in
@@ -2591,12 +2592,17 @@ pick_next_task(struct rq *rq, struct task_struct *prev)
if (likely(prev->sched_class == class &&
rq->nr_running == rq->cfs.h_nr_running)) {
p = fair_sched_class.pick_next_task(rq, prev);
- if (likely(p && p != RETRY_TASK))
+ if (!p)
+ skip_fair = 1;
+ else if (likely(p != RETRY_TASK))
return p;
}
again:
for_each_class(class) {
+ /* if we have already failed to pull fair task, skip */
+ if (class == &fair_sched_class && skip_fair)
+ continue;
p = class->pick_next_task(rq, prev);
if (p) {
if (unlikely(p == RETRY_TASK))
--
1.7.11.7
next reply other threads:[~2014-04-23 22:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-23 22:31 Tim Chen [this message]
2014-04-24 10:00 ` Peter Zijlstra
2014-04-24 17:06 ` Tim Chen
2014-04-24 17:16 ` Peter Zijlstra
2014-05-08 10:42 ` [tip:sched/core] sched: Skip double execution of pick_next_task_fair() tip-bot for 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=1398292317.2970.63.camel@schen9-DESK \
--to=tim.c.chen@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®