summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-01-18 18:30:12 -0800
committerLinus Torvalds <torvalds@home.osdl.org>2004-01-18 18:30:12 -0800
commit67006113bec9bbe326f9e862295183182115e5fb (patch)
tree910a2a419e9890b7f02e3a6d643725ed406a2736 /kernel
parent8c6f4906c0e0b0229967551a9ddafd8685f1c563 (diff)
[PATCH] Relax synchronization of sched_clock()
From: Ingo Molnar <mingo@elte.hu> - relax synchronization of sched_clock()
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index ce5639a4bc5c..0e2b65cffa52 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -199,7 +199,7 @@ struct prio_array {
struct runqueue {
spinlock_t lock;
unsigned long nr_running, nr_switches, expired_timestamp,
- nr_uninterruptible;
+ nr_uninterruptible, timestamp_last_tick;
task_t *curr, *idle;
struct mm_struct *prev_mm;
prio_array_t *active, *expired, arrays[2];
@@ -1137,6 +1137,7 @@ static inline void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t
set_task_cpu(p, this_cpu);
nr_running_inc(this_rq);
enqueue_task(p, this_rq->active);
+ p->timestamp = sched_clock() - (src_rq->timestamp_last_tick - p->timestamp);
/*
* Note that idle threads have a prio of MAX_PRIO, for this test
* to be always true for them.
@@ -1157,7 +1158,7 @@ static inline void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t
static inline int
can_migrate_task(task_t *tsk, runqueue_t *rq, int this_cpu, int idle)
{
- unsigned long delta = sched_clock() - tsk->timestamp;
+ unsigned long delta = rq->timestamp_last_tick - tsk->timestamp;
if (!idle && (delta <= JIFFIES_TO_NS(cache_decay_ticks)))
return 0;
@@ -1365,6 +1366,8 @@ void scheduler_tick(int user_ticks, int sys_ticks)
runqueue_t *rq = this_rq();
task_t *p = current;
+ rq->timestamp_last_tick = sched_clock();
+
if (rcu_pending(cpu))
rcu_check_callbacks(cpu, user_ticks);
@@ -2641,6 +2644,8 @@ static void move_task_away(struct task_struct *p, int dest_cpu)
if (p->prio < rq_dest->curr->prio)
resched_task(rq_dest->curr);
}
+ p->timestamp = rq_dest->timestamp_last_tick;
+
out:
double_rq_unlock(this_rq(), rq_dest);
local_irq_restore(flags);