Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58273
b: refs/heads/master
c: 20d315d
h: refs/heads/master
i:
  58271: fa36a9d
v: v3
  • Loading branch information
Ingo Molnar committed Jul 9, 2007
1 parent f7e8e65 commit f809a03
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6aa645ea5f7a246702e07f29edc7075d487ae4a3
refs/heads/master: 20d315d42aed95423a7203e1d7e84086004b5a00
46 changes: 46 additions & 0 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,52 @@ static inline int cpu_of(struct rq *rq)
#endif
}

/*
* Per-runqueue clock, as finegrained as the platform can give us:
*/
static unsigned long long __rq_clock(struct rq *rq)
{
u64 prev_raw = rq->prev_clock_raw;
u64 now = sched_clock();
s64 delta = now - prev_raw;
u64 clock = rq->clock;

/*
* Protect against sched_clock() occasionally going backwards:
*/
if (unlikely(delta < 0)) {
clock++;
rq->clock_warps++;
} else {
/*
* Catch too large forward jumps too:
*/
if (unlikely(delta > 2*TICK_NSEC)) {
clock++;
rq->clock_overflows++;
} else {
if (unlikely(delta > rq->clock_max_delta))
rq->clock_max_delta = delta;
clock += delta;
}
}

rq->prev_clock_raw = now;
rq->clock = clock;

return clock;
}

static inline unsigned long long rq_clock(struct rq *rq)
{
int this_cpu = smp_processor_id();

if (this_cpu == cpu_of(rq))
return __rq_clock(rq);

return rq->clock;
}

/*
* The domain tree (rq->sd) is protected by RCU's quiescent state transition.
* See detach_destroy_domains: synchronize_sched for details.
Expand Down

0 comments on commit f809a03

Please sign in to comment.