Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96046
b: refs/heads/master
c: dfbf4a1
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed May 5, 2008
1 parent 74921d8 commit c737419
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb4ad1ffc7c0d8ea7dc8cd8ba303d83551716d46
refs/heads/master: dfbf4a1bc319f0f9a31e39b2da1fa5c55e85af89
24 changes: 15 additions & 9 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,11 +910,14 @@ static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);
static DEFINE_SPINLOCK(time_sync_lock);
static unsigned long long prev_global_time;

static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)
static unsigned long long __sync_cpu_clock(unsigned long long time, int cpu)
{
unsigned long flags;

spin_lock_irqsave(&time_sync_lock, flags);
/*
* We want this inlined, to not get tracer function calls
* in this critical section:
*/
spin_acquire(&time_sync_lock.dep_map, 0, 0, _THIS_IP_);
__raw_spin_lock(&time_sync_lock.raw_lock);

if (time < prev_global_time) {
per_cpu(time_offset, cpu) += prev_global_time - time;
Expand All @@ -923,15 +926,15 @@ static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)
prev_global_time = time;
}

spin_unlock_irqrestore(&time_sync_lock, flags);
__raw_spin_unlock(&time_sync_lock.raw_lock);
spin_release(&time_sync_lock.dep_map, 1, _THIS_IP_);

return time;
}

static unsigned long long __cpu_clock(int cpu)
{
unsigned long long now;
unsigned long flags;
struct rq *rq;

/*
Expand All @@ -941,11 +944,9 @@ static unsigned long long __cpu_clock(int cpu)
if (unlikely(!scheduler_running))
return 0;

local_irq_save(flags);
rq = cpu_rq(cpu);
update_rq_clock(rq);
now = rq->clock;
local_irq_restore(flags);

return now;
}
Expand All @@ -957,13 +958,18 @@ static unsigned long long __cpu_clock(int cpu)
unsigned long long cpu_clock(int cpu)
{
unsigned long long prev_cpu_time, time, delta_time;
unsigned long flags;

local_irq_save(flags);
prev_cpu_time = per_cpu(prev_cpu_time, cpu);
time = __cpu_clock(cpu) + per_cpu(time_offset, cpu);
delta_time = time-prev_cpu_time;

if (unlikely(delta_time > time_sync_thresh))
if (unlikely(delta_time > time_sync_thresh)) {
time = __sync_cpu_clock(time, cpu);
per_cpu(prev_cpu_time, cpu) = time;
}
local_irq_restore(flags);

return time;
}
Expand Down

0 comments on commit c737419

Please sign in to comment.