From: "tip-bot for Gustavo A. R. Silva" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, wanpeng.li@hotmail.com,
tglx@linutronix.de, peterz@infradead.org, sgruszka@redhat.com,
garsilva@embeddedor.com, hpa@zytor.com, fransklaver@gmail.com,
mingo@kernel.org, torvalds@linux-foundation.org, riel@redhat.com,
fweisbec@gmail.com
Subject: [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code
Date: Fri, 30 Jun 2017 06:10:35 -0700 [thread overview]
Message-ID: <tip-72298e5c92c50edd8cb7cfda4519483ce65fa166@git.kernel.org> (raw)
In-Reply-To: <20170629184128.GA5271@embeddedgus>
Commit-ID: 72298e5c92c50edd8cb7cfda4519483ce65fa166
Gitweb: http://git.kernel.org/tip/72298e5c92c50edd8cb7cfda4519483ce65fa166
Author: Gustavo A. R. Silva <garsilva@embeddedor.com>
AuthorDate: Thu, 29 Jun 2017 13:41:28 -0500
Committer: Ingo Molnar <mingo@kernel.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@embeddedor.com>
Cc: Frans Klaver <fransklaver@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.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>
Link: http://lkml.kernel.org/r/20170629184128.GA5271@embeddedgus
Signed-off-by: Ingo Molnar <mingo@kernel.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.
next prev parent reply other threads:[~2017-06-30 13:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 23:03 [kernel-sched-cputime] question about probable bug in cputime_adjust() Gustavo A. R. Silva
2017-06-28 5:35 ` Frans Klaver
2017-06-28 6:03 ` Frans Klaver
2017-06-28 23:57 ` Gustavo A. R. Silva
2017-06-29 4:51 ` Frans Klaver
2017-06-29 17:58 ` Gustavo A. R. Silva
2017-06-29 18:41 ` [PATCH] sched/cputime: code refactoring " Gustavo A. R. Silva
2017-06-30 13:10 ` tip-bot for Gustavo A. R. Silva [this message]
2017-06-30 14:00 ` [tip:sched/core] sched/cputime: Refactor the cputime_adjust() code Rik van Riel
2017-06-30 14:41 ` Frans Klaver
2017-06-30 15:46 ` Frederic Weisbecker
2017-06-30 16:17 ` Stanislaw Gruszka
2017-07-04 9:17 ` Peter Zijlstra
2017-07-04 10:01 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-72298e5c92c50edd8cb7cfda4519483ce65fa166@git.kernel.org \
--to=tipbot@zytor.com \
--cc=fransklaver@gmail.com \
--cc=fweisbec@gmail.com \
--cc=garsilva@embeddedor.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=sgruszka@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=wanpeng.li@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox