aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-09-06 10:51:57 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-06 10:51:57 -0400
commit7f79d852ed30a06eebf7497afe9334a726db3d40 (patch)
tree0057281f17501b635d3d88cda9a14203706f5dcc /kernel/sched.c
parentaef745fca016aea45adae5c98e8698904dd8ad51 (diff)
parent70bb08962ea9bd50797ae9f16b2493f5f7c65053 (diff)
Merge branch 'linus' into sched/devel
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index b112caaa400a..8626ae50ce08 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4176,6 +4176,65 @@ void account_steal_time(struct task_struct *p, cputime_t steal)
4176} 4176}
4177 4177
4178/* 4178/*
4179 * Use precise platform statistics if available:
4180 */
4181#ifdef CONFIG_VIRT_CPU_ACCOUNTING
4182cputime_t task_utime(struct task_struct *p)
4183{
4184 return p->utime;
4185}
4186
4187cputime_t task_stime(struct task_struct *p)
4188{
4189 return p->stime;
4190}
4191#else
4192cputime_t task_utime(struct task_struct *p)
4193{
4194 clock_t utime = cputime_to_clock_t(p->utime),
4195 total = utime + cputime_to_clock_t(p->stime);
4196 u64 temp;
4197
4198 /*
4199 * Use CFS's precise accounting:
4200 */
4201 temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime);
4202
4203 if (total) {
4204 temp *= utime;
4205 do_div(temp, total);
4206 }
4207 utime = (clock_t)temp;
4208
4209 p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime));
4210 return p->prev_utime;
4211}
4212
4213cputime_t task_stime(struct task_struct *p)
4214{
4215 clock_t stime;
4216
4217 /*
4218 * Use CFS's precise accounting. (we subtract utime from
4219 * the total, to make sure the total observed by userspace
4220 * grows monotonically - apps rely on that):
4221 */
4222 stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
4223 cputime_to_clock_t(task_utime(p));
4224
4225 if (stime >= 0)
4226 p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime));
4227
4228 return p->prev_stime;
4229}
4230#endif
4231
4232inline cputime_t task_gtime(struct task_struct *p)
4233{
4234 return p->gtime;
4235}
4236
4237/*
4179 * This function gets called by the timer code, with HZ frequency. 4238 * This function gets called by the timer code, with HZ frequency.
4180 * We call it with interrupts disabled. 4239 * We call it with interrupts disabled.
4181 * 4240 *