Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169898
b: refs/heads/master
c: 761b1d2
h: refs/heads/master
v: v3
  • Loading branch information
Hidetoshi Seto authored and Ingo Molnar committed Nov 12, 2009
1 parent 69472c0 commit b8e703e
Show file tree
Hide file tree
Showing 2 changed files with 14 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: ffd44db5f02af32bcc25a8eb5981bf02a141cdab
refs/heads/master: 761b1d26df542fd5eb348837351e4d2f3bc7bffe
22 changes: 13 additions & 9 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5156,41 +5156,45 @@ cputime_t task_stime(struct task_struct *p)
return p->stime;
}
#else

#ifndef nsecs_to_cputime
# define nsecs_to_cputime(__nsecs) \
msecs_to_cputime(div_u64((__nsecs), NSEC_PER_MSEC))
#endif

cputime_t task_utime(struct task_struct *p)
{
clock_t utime = cputime_to_clock_t(p->utime),
total = utime + cputime_to_clock_t(p->stime);
cputime_t utime = p->utime, total = utime + p->stime;
u64 temp;

/*
* Use CFS's precise accounting:
*/
temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime);
temp = (u64)nsecs_to_cputime(p->se.sum_exec_runtime);

if (total) {
temp *= utime;
do_div(temp, total);
}
utime = (clock_t)temp;
utime = (cputime_t)temp;

p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime));
p->prev_utime = max(p->prev_utime, utime);
return p->prev_utime;
}

cputime_t task_stime(struct task_struct *p)
{
clock_t stime;
cputime_t stime;

/*
* Use CFS's precise accounting. (we subtract utime from
* the total, to make sure the total observed by userspace
* grows monotonically - apps rely on that):
*/
stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
cputime_to_clock_t(task_utime(p));
stime = nsecs_to_cputime(p->se.sum_exec_runtime) - task_utime(p);

if (stime >= 0)
p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime));
p->prev_stime = max(p->prev_stime, stime);

return p->prev_stime;
}
Expand Down

0 comments on commit b8e703e

Please sign in to comment.