Re: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-28 Thread Jon Hunter


On 28/02/2019 12:31, Peter Zijlstra wrote:
> 
> Clearly, because reading comprehension isn't your strong point:
> 
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing in e-mail?

Sorry we have a few people helping out cleaning up our kernel branches
and we need to do a better job here indeed!

> On Thu, Feb 28, 2019 at 12:14:09PM +, Sachin Nikam wrote:
> 
>> This isn't a security fix.
>> However, I see this is kind of code cleanup.
> 
> As I've explained previously, it makes conceptual sense to have it in
> the code, and any halfway sane compiler will observe the same double
> store and eliminate it in its DCE pass.

OK. Thanks for the feedback. We can agree to drop this and we will try
to do a better job reviewing this type of thing before hand in future.

Cheers
Jon

-- 
nvpublic


Re: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-28 Thread Peter Zijlstra


Clearly, because reading comprehension isn't your strong point:

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

On Thu, Feb 28, 2019 at 12:14:09PM +, Sachin Nikam wrote:

> This isn't a security fix.
> However, I see this is kind of code cleanup.

As I've explained previously, it makes conceptual sense to have it in
the code, and any halfway sane compiler will observe the same double
store and eliminate it in its DCE pass.


RE: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-28 Thread Sachin Nikam
Ketan,
What is the Coverity Impact Level for this defect?
If it is Low then we can whitelist this defect and change.

Peter,
This isn't a security fix.
However, I see this is kind of code cleanup.

-Original Message-
From: Peter Zijlstra  
Sent: Thursday, February 28, 2019 3:18 PM
To: Ketan Patil 
Cc: mi...@redhat.com; linux-kernel@vger.kernel.org; 
linux-te...@vger.kernel.org; Sachin Nikam ; Bharat Nihalani 
; Bo Yan ; Sai Gurrappadi 
; Thierry Reding ; Timo Alho 

Subject: Re: [PATCH] sched/cputime: Remove unnecessary assignment statement


A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

On Thu, Feb 28, 2019 at 03:12:13PM +0530, Ketan Patil wrote:
> The coverity tool has detected this issue as an unused value, since 
> the code assigns the value to utime variable and then after the jump, 
> the value of utime again gets updated, hence the previous value is not 
> at all useful and this patch removes that first assignment.

Not a security issue then; just tell coverity to shut up.


Re: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-28 Thread Peter Zijlstra


A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

On Thu, Feb 28, 2019 at 03:12:13PM +0530, Ketan Patil wrote:
> The coverity tool has detected this issue as an unused value, since
> the code assigns the value to utime variable and then after the jump, the
> value of utime again gets updated, hence the previous value is not at all
> useful and this patch removes that first assignment.

Not a security issue then; just tell coverity to shut up.


Re: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-28 Thread Ketan Patil

The coverity tool has detected this issue as an unused value, since

the code assigns the value to utime variable and then after the jump, the

value of utime again gets updated, hence the previous value is not at all

useful and this patch removes that first assignment.

On 27/02/19 4:02 PM, Peter Zijlstra wrote:

On Wed, Feb 27, 2019 at 11:43:22AM +0530, Ketan Patil wrote:

The original code assigns the value from rtime to utime variable,
and then jumps to the update label. And the value of utime is then
updated, so the earlier value of utime is not used. Hence remove
that unnecessary assignment statement.

This fixes one of the coverity defects.

Why does coverity care? I like the way the code is now, it makes
conceptual sense. Removing that assignment makes the code harder to read
and less symmetric (see the utime case right below).

Any sensible compiler will 'fix' this for us anyway.


Based on work by Ishan Mittal 
Signed-off-by: Ketan Patil 
---
  kernel/sched/cputime.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index ba4a143..ad64771 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct 
prev_cputime *prev,
 * Once a task gets some ticks, the monotonicy code at 'update:'
 * will ensure things converge to the observed ratio.
 */
-   if (stime == 0) {
-   utime = rtime;
+   if (stime == 0)
goto update;
-   }
  
  	if (utime == 0) {

stime = rtime;


Re: [PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-27 Thread Peter Zijlstra
On Wed, Feb 27, 2019 at 11:43:22AM +0530, Ketan Patil wrote:
> The original code assigns the value from rtime to utime variable,
> and then jumps to the update label. And the value of utime is then
> updated, so the earlier value of utime is not used. Hence remove
> that unnecessary assignment statement.
> 
> This fixes one of the coverity defects.

Why does coverity care? I like the way the code is now, it makes
conceptual sense. Removing that assignment makes the code harder to read
and less symmetric (see the utime case right below).

Any sensible compiler will 'fix' this for us anyway.

> Based on work by Ishan Mittal 
> Signed-off-by: Ketan Patil 
> ---
>  kernel/sched/cputime.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index ba4a143..ad64771 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct 
> prev_cputime *prev,
>* Once a task gets some ticks, the monotonicy code at 'update:'
>* will ensure things converge to the observed ratio.
>*/
> - if (stime == 0) {
> - utime = rtime;
> + if (stime == 0)
>   goto update;
> - }
>  
>   if (utime == 0) {
>   stime = rtime;



[PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-26 Thread Ketan Patil
The original code assigns the value from rtime to utime variable,
and then jumps to the update label. And the value of utime is then
updated, so the earlier value of utime is not used. Hence remove
that unnecessary assignment statement.

This fixes one of the coverity defects.

Based on work by Ishan Mittal 

Signed-off-by: Ketan Patil 
---
 kernel/sched/cputime.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index ba4a143..ad64771 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct 
prev_cputime *prev,
 * Once a task gets some ticks, the monotonicy code at 'update:'
 * will ensure things converge to the observed ratio.
 */
-   if (stime == 0) {
-   utime = rtime;
+   if (stime == 0)
goto update;
-   }
 
if (utime == 0) {
stime = rtime;
-- 
2.7.4