From: Daniel Walker <dwalker@mvista.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, mingo@elte.hu
Subject: [PATCH] sched: consolidate sched_clock drift adjustments
Date: Wed, 11 Apr 2007 13:26:18 -0700 [thread overview]
Message-ID: <20070411202618.047341551@mvista.com> (raw)
No functional changes ..
I created sched_clock_drift_adjust() which holds similar code from
different places in the scheduler which all appear to do the same thing.
I also added an explicit ifdef on CONFIG_SMP, the comments seemed to
suggest it wasn't needed, but it can't hurt to make it explicit .
Signed-Off-By: Daniel Walker <dwalker@mvista.com>
---
kernel/sched.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
Index: linux-2.6.20/kernel/sched.c
===================================================================
--- linux-2.6.20.orig/kernel/sched.c
+++ linux-2.6.20/kernel/sched.c
@@ -659,6 +659,20 @@ sched_info_switch(struct task_struct *pr
#define sched_info_switch(t, next) do { } while (0)
#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#ifdef CONFIG_SMP
+static inline unsigned long long
+sched_clock_drift_adjust(unsigned long long timestamp, struct rq *from,
+ struct rq *to)
+{
+ return (timestamp - from->most_recent_timestamp)
+ + to->most_recent_timestamp;
+}
+#else
+static inline unsigned long long
+sched_clock_drift_adjust(unsigned long long timestamp, struct rq *from,
+ struct rq *to) { }
+#endif
+
static inline int task_queued(struct task_struct *task)
{
return !list_empty(&task->run_list);
@@ -1018,10 +1032,10 @@ static void activate_task(struct task_st
#ifdef CONFIG_SMP
if (!local) {
- /* Compensate for drifting sched_clock */
struct rq *this_rq = this_rq();
- now = (now - this_rq->most_recent_timestamp)
- + rq->most_recent_timestamp;
+
+ /* Compensate for drifting sched_clock */
+ now = sched_clock_drift_adjust(now, this_rq, rq);
}
#endif
@@ -1742,8 +1756,8 @@ void fastcall wake_up_new_task(struct ta
* Not the local CPU - must adjust timestamp. This should
* get optimised away in the !CONFIG_SMP case.
*/
- p->timestamp = (p->timestamp - this_rq->most_recent_timestamp)
- + rq->most_recent_timestamp;
+ p->timestamp =
+ sched_clock_drift_adjust(p->timestamp, this_rq, rq);
activate_task(p, rq, 0);
try_preempt(p, rq);
@@ -2118,8 +2132,7 @@ static void pull_task(struct rq *src_rq,
set_task_cpu(p, this_cpu);
inc_nr_running(p, this_rq);
enqueue_task(p, this_rq);
- p->timestamp = (p->timestamp - src_rq->most_recent_timestamp)
- + this_rq->most_recent_timestamp;
+ p->timestamp = sched_clock_drift_adjust(p->timestamp, src_rq, this_rq);
try_preempt(p, this_rq);
}
@@ -5054,8 +5067,8 @@ static int __migrate_task(struct task_st
* afterwards, and pretending it was a local activate.
* This way is cleaner and logically correct.
*/
- p->timestamp = p->timestamp - rq_src->most_recent_timestamp
- + rq_dest->most_recent_timestamp;
+ p->timestamp =
+ sched_clock_drift_adjust(p->timestamp, rq_src, rq_dest);
deactivate_task(p, rq_src);
__activate_task(p, rq_dest);
try_preempt(p, rq_dest);
--
--
reply other threads:[~2007-04-11 20:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070411202618.047341551@mvista.com \
--to=dwalker@mvista.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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®