aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/cputime.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched/cputime.c')
-rw-r--r--kernel/sched/cputime.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 7dc155371b95..220fdc4db770 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -516,14 +516,18 @@ static cputime_t scale_utime(cputime_t utime, cputime_t rtime, cputime_t total)
516 return (__force cputime_t) temp; 516 return (__force cputime_t) temp;
517} 517}
518 518
519void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st) 519static void cputime_adjust(struct task_cputime *curr,
520 struct cputime *prev,
521 cputime_t *ut, cputime_t *st)
520{ 522{
521 cputime_t rtime, utime = p->utime, total = utime + p->stime; 523 cputime_t rtime, utime, total;
522 524
525 utime = curr->utime;
526 total = utime + curr->stime;
523 /* 527 /*
524 * Use CFS's precise accounting: 528 * Use CFS's precise accounting:
525 */ 529 */
526 rtime = nsecs_to_cputime(p->se.sum_exec_runtime); 530 rtime = nsecs_to_cputime(curr->sum_exec_runtime);
527 531
528 if (total) 532 if (total)
529 utime = scale_utime(utime, rtime, total); 533 utime = scale_utime(utime, rtime, total);
@@ -533,11 +537,22 @@ void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
533 /* 537 /*
534 * Compare with previous values, to keep monotonicity: 538 * Compare with previous values, to keep monotonicity:
535 */ 539 */
536 p->prev_utime = max(p->prev_utime, utime); 540 prev->utime = max(prev->utime, utime);
537 p->prev_stime = max(p->prev_stime, rtime - p->prev_utime); 541 prev->stime = max(prev->stime, rtime - prev->utime);
542
543 *ut = prev->utime;
544 *st = prev->stime;
545}
538 546
539 *ut = p->prev_utime; 547void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
540 *st = p->prev_stime; 548{
549 struct task_cputime cputime = {
550 .utime = p->utime,
551 .stime = p->stime,
552 .sum_exec_runtime = p->se.sum_exec_runtime,
553 };
554
555 cputime_adjust(&cputime, &p->prev_cputime, ut, st);
541} 556}
542 557
543/* 558/*
@@ -545,24 +560,9 @@ void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
545 */ 560 */
546void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st) 561void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
547{ 562{
548 struct signal_struct *sig = p->signal;
549 struct task_cputime cputime; 563 struct task_cputime cputime;
550 cputime_t rtime, utime, total;
551 564
552 thread_group_cputime(p, &cputime); 565 thread_group_cputime(p, &cputime);
553 566 cputime_adjust(&cputime, &p->signal->prev_cputime, ut, st);
554 total = cputime.utime + cputime.stime;
555 rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
556
557 if (total)
558 utime = scale_utime(cputime.utime, rtime, total);
559 else
560 utime = rtime;
561
562 sig->prev_utime = max(sig->prev_utime, utime);
563 sig->prev_stime = max(sig->prev_stime, rtime - sig->prev_utime);
564
565 *ut = sig->prev_utime;
566 *st = sig->prev_stime;
567} 567}
568#endif 568#endif