From: Jupyung Lee <jupyung@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@redhat.com>, Jupyung Lee <jupyung@gmail.com>
Subject: [PATCH 1/1] sched: move update_curr() in check_preempt_wakeup() to avoid redundant call
Date: Tue, 17 Nov 2009 18:51:40 +0900 [thread overview]
Message-ID: <1258451500-6714-1-git-send-email-jupyung@gmail.com> (raw)
Impact: micro-optimization
If a RT task is woken up while a non-RT task is running,
check_preempt_wakeup() is called to check whether the new task can
preempt the old task. The function returns quickly without going deeper
because it is apparent that a RT task can always preempt a non-RT task.
In this situation, check_preempt_wakeup() always calls update_curr() to
update vruntime value of the currently running task. However, the function
call is unnecessary and redundant at that moment because (1) a non-RT task can
always be preempted by a RT task regardless of its vruntime value, and
(2) update_curr() will be called shortly when the context switch between two occurs.
By moving update_curr() in check_preempt_wakeup(), we can avoid redundant
call to update_curr(), slightly reducing the time taken to wake up RT tasks.
Signed-off-by: Jupyung Lee <jupyung@gmail.com>
---
kernel/sched_fair.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 37087a7..32256c0 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1596,8 +1596,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
int sync = wake_flags & WF_SYNC;
int scale = cfs_rq->nr_running >= sched_nr_latency;
- update_curr(cfs_rq);
-
if (unlikely(rt_prio(p->prio))) {
resched_task(curr);
return;
@@ -1655,6 +1653,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
BUG_ON(!pse);
+ update_curr(cfs_rq);
+
if (wakeup_preempt_entity(se, pse) == 1) {
resched_task(curr);
/*
--
1.6.5.GIT
next reply other threads:[~2009-11-17 9:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 9:51 Jupyung Lee [this message]
2009-11-19 22:51 ` Peter Zijlstra
2009-11-20 8:26 ` jupyung lee
2009-12-09 9:54 ` [tip:sched/urgent] sched: Move " tip-bot for Jupyung Lee
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=1258451500-6714-1-git-send-email-jupyung@gmail.com \
--to=jupyung@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.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
all inboxes | Powered by JetHome®