Skip to content

Commit 57d7309

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull cputime fix from Ingo Molnar: "This fixes a longer-standing cputime accounting bug that Stanislaw Gruszka finally managed to track down" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/cputime: Do not scale when utime == 0
2 parents 050ba07 + 5a8e01f commit 57d7309

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎kernel/sched/cputime.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,7 @@ static void cputime_adjust(struct task_cputime *curr,
551551
struct cputime *prev,
552552
cputime_t *ut, cputime_t *st)
553553
{
554-
cputime_t rtime, stime, utime, total;
555-
556-
stime = curr->stime;
557-
total = stime + curr->utime;
554+
cputime_t rtime, stime, utime;
558555

559556
/*
560557
* Tick based cputime accounting depend on random scheduling
@@ -576,13 +573,19 @@ static void cputime_adjust(struct task_cputime *curr,
576573
if (prev->stime + prev->utime >= rtime)
577574
goto out;
578575

579-
if (total) {
576+
stime = curr->stime;
577+
utime = curr->utime;
578+
579+
if (utime == 0) {
580+
stime = rtime;
581+
} else if (stime == 0) {
582+
utime = rtime;
583+
} else {
584+
cputime_t total = stime + utime;
585+
580586
stime = scale_stime((__force u64)stime,
581587
(__force u64)rtime, (__force u64)total);
582588
utime = rtime - stime;
583-
} else {
584-
stime = rtime;
585-
utime = 0;
586589
}
587590

588591
/*

0 commit comments

Comments
 (0)