aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-07-04 05:53:40 -0400
committerIngo Molnar <mingo@kernel.org>2017-07-04 05:58:05 -0400
commit3b9c08ae3dd44201b3a188aef34d6ddf73434015 (patch)
treee2c36ee566d82c3e170abac710f4af0b966f9e50
parent4422d80ed7d4bdb2d6e9fb890c66c3d9250ba694 (diff)
Revert "sched/cputime: Refactor the cputime_adjust() code"
This reverts commit 72298e5c92c50edd8cb7cfda4519483ce65fa166. As Peter explains: > Argh, no... That code was perfectly fine. The new code otoh is > convoluted. > > The old code had the following form: > > if (exception1) > deal with exception1 > > if (execption2) > deal with exception2 > > do normal stuff > > Which is as simple and straight forward as it gets. > > The new code otoh reads like: > > if (!exception1) { > if (exception2) > deal with exception 2 > else > do normal stuff > } So restore the old form. Also fix the comment describing the logic, as it was confusing. Requested-by: Peter Zijlstra <peterz@infradead.org> Cc: Gustavo A. R. Silva <garsilva@embeddedor.com> Cc: Frans Klaver <fransklaver@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Rik van Riel <riel@redhat.com> Cc: Stanislaw Gruszka <sgruszka@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wanpeng Li <wanpeng.li@hotmail.com> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--kernel/sched/cputime.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 67c70e287647..84a419bdf5aa 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -611,17 +611,23 @@ static void cputime_adjust(struct task_cputime *curr,
611 utime = curr->utime; 611 utime = curr->utime;
612 612
613 /* 613 /*
614 * If either stime or both stime and utime are 0, assume all runtime is 614 * If either stime or utime are 0, assume all runtime is userspace.
615 * userspace. Once a task gets some ticks, the monotonicy code at 615 * Once a task gets some ticks, the monotonicy code at 'update:'
616 * 'update' will ensure things converge to the observed ratio. 616 * will ensure things converge to the observed ratio.
617 */ 617 */
618 if (stime != 0) { 618 if (stime == 0) {
619 if (utime == 0) 619 utime = rtime;
620 stime = rtime; 620 goto update;
621 else
622 stime = scale_stime(stime, rtime, stime + utime);
623 } 621 }
624 622
623 if (utime == 0) {
624 stime = rtime;
625 goto update;
626 }
627
628 stime = scale_stime(stime, rtime, stime + utime);
629
630update:
625 /* 631 /*
626 * Make sure stime doesn't go backwards; this preserves monotonicity 632 * Make sure stime doesn't go backwards; this preserves monotonicity
627 * for utime because rtime is monotonic. 633 * for utime because rtime is monotonic.