Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339092
b: refs/heads/master
c: fa09205
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker committed Nov 28, 2012
1 parent 0cba12e commit 0792538
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 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: d37f761dbd276790f70dcf73a287fde2c3464482
refs/heads/master: fa09205783d11cc05122ad6e4ce06074624b2c0c
18 changes: 16 additions & 2 deletions trunk/kernel/sched/cputime.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ static cputime_t scale_utime(cputime_t utime, cputime_t rtime, cputime_t total)
return (__force cputime_t) temp;
}

/*
* Adjust tick based cputime random precision against scheduler
* runtime accounting.
*/
static void cputime_adjust(struct task_cputime *curr,
struct cputime *prev,
cputime_t *ut, cputime_t *st)
Expand All @@ -524,8 +528,16 @@ static void cputime_adjust(struct task_cputime *curr,

utime = curr->utime;
total = utime + curr->stime;

/*
* Use CFS's precise accounting:
* Tick based cputime accounting depend on random scheduling
* timeslices of a task to be interrupted or not by the timer.
* Depending on these circumstances, the number of these interrupts
* may be over or under-optimistic, matching the real user and system
* cputime with a variable precision.
*
* Fix this by scaling these tick based values against the total
* runtime accounted by the CFS scheduler.
*/
rtime = nsecs_to_cputime(curr->sum_exec_runtime);

Expand All @@ -535,7 +547,9 @@ static void cputime_adjust(struct task_cputime *curr,
utime = rtime;

/*
* Compare with previous values, to keep monotonicity:
* If the tick based count grows faster than the scheduler one,
* the result of the scaling may go backward.
* Let's enforce monotonicity.
*/
prev->utime = max(prev->utime, utime);
prev->stime = max(prev->stime, rtime - prev->utime);
Expand Down

0 comments on commit 0792538

Please sign in to comment.