[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-72298e5c92c50edd8cb7cfda4519483ce65fa166@git.kernel.org>
Date: Fri, 30 Jun 2017 06:10:35 -0700
From: "tip-bot for Gustavo A. R. Silva" <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, wanpeng.li@...mail.com,
tglx@...utronix.de, peterz@...radead.org, sgruszka@...hat.com,
garsilva@...eddedor.com, hpa@...or.com, fransklaver@...il.com,
mingo@...nel.org, torvalds@...ux-foundation.org, riel@...hat.com,
fweisbec@...il.com
Subject: [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code
Commit-ID: 72298e5c92c50edd8cb7cfda4519483ce65fa166
Gitweb: http://git.kernel.org/tip/72298e5c92c50edd8cb7cfda4519483ce65fa166
Author: Gustavo A. R. Silva <garsilva@...eddedor.com>
AuthorDate: Thu, 29 Jun 2017 13:41:28 -0500
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Fri, 30 Jun 2017 09:37:59 +0200
sched/cputime: Refactor the cputime_adjust() code
Address a Coverity false positive, which is caused by overly
convoluted code:
Value assigned to variable 'utime' at line 619:utime = rtime;
is overwritten at line 642:utime = rtime - stime; before it
can be used. This makes such variable assignment useless.
Remove this variable assignment and refactor the code related.
Addresses-Coverity-ID: 1371643
Signed-off-by: Gustavo A. R. Silva <garsilva@...eddedor.com>
Cc: Frans Klaver <fransklaver@...il.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rik van Riel <riel@...hat.com>
Cc: Stanislaw Gruszka <sgruszka@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Wanpeng Li <wanpeng.li@...mail.com>
Link: http://lkml.kernel.org/r/20170629184128.GA5271@embeddedgus
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/sched/cputime.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index aea3135..67c70e2 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -615,19 +615,13 @@ static void cputime_adjust(struct task_cputime *curr,
* userspace. Once a task gets some ticks, the monotonicy code at
* 'update' will ensure things converge to the observed ratio.
*/
- if (stime == 0) {
- utime = rtime;
- goto update;
+ if (stime != 0) {
+ if (utime == 0)
+ stime = rtime;
+ else
+ stime = scale_stime(stime, rtime, stime + utime);
}
- if (utime == 0) {
- stime = rtime;
- goto update;
- }
-
- stime = scale_stime(stime, rtime, stime + utime);
-
-update:
/*
* Make sure stime doesn't go backwards; this preserves monotonicity
* for utime because rtime is monotonic.
Powered by blists - more mailing lists