linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Return true,false in voluntary_active_balance()
@ 2020-05-07 11:06 Jason Yan
  2020-05-07 11:17 ` Valentin Schneider
  2020-05-08  8:16 ` Peter Zijlstra
  0 siblings, 2 replies; 13+ messages in thread
From: Jason Yan @ 2020-05-07 11:06 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, linux-kernel
  Cc: Jason Yan

Fix the following coccicheck warning:

kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
'voluntary_active_balance' with return type bool

Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 kernel/sched/fair.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b3bb4d6e49c3..e8390106ada4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9373,7 +9373,7 @@ voluntary_active_balance(struct lb_env *env)
 	struct sched_domain *sd = env->sd;
 
 	if (asym_active_balance(env))
-		return 1;
+		return true;
 
 	/*
 	 * The dst_cpu is idle and the src_cpu CPU has only 1 CFS task.
@@ -9385,13 +9385,13 @@ voluntary_active_balance(struct lb_env *env)
 	    (env->src_rq->cfs.h_nr_running == 1)) {
 		if ((check_cpu_capacity(env->src_rq, sd)) &&
 		    (capacity_of(env->src_cpu)*sd->imbalance_pct < capacity_of(env->dst_cpu)*100))
-			return 1;
+			return true;
 	}
 
 	if (env->migration_type == migrate_misfit)
-		return 1;
+		return true;
 
-	return 0;
+	return false;
 }
 
 static int need_active_balance(struct lb_env *env)
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 11:06 [PATCH] sched/fair: Return true,false in voluntary_active_balance() Jason Yan
@ 2020-05-07 11:17 ` Valentin Schneider
  2020-05-07 17:28   ` Steven Rostedt
  2020-05-08  8:16 ` Peter Zijlstra
  1 sibling, 1 reply; 13+ messages in thread
From: Valentin Schneider @ 2020-05-07 11:17 UTC (permalink / raw)
  To: Jason Yan
  Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, linux-kernel


On 07/05/20 12:06, Jason Yan wrote:
> Fix the following coccicheck warning:
>
> kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
> 'voluntary_active_balance' with return type bool
>

It's perfectly safe to return 0/1 in a boolean function; that said seeing
as this is the second attempt at "fixing" this I'm tempted to say we should
pick it up...

> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> ---
>  kernel/sched/fair.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index b3bb4d6e49c3..e8390106ada4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9373,7 +9373,7 @@ voluntary_active_balance(struct lb_env *env)
>       struct sched_domain *sd = env->sd;
>
>       if (asym_active_balance(env))
> -		return 1;
> +		return true;
>
>       /*
>        * The dst_cpu is idle and the src_cpu CPU has only 1 CFS task.
> @@ -9385,13 +9385,13 @@ voluntary_active_balance(struct lb_env *env)
>           (env->src_rq->cfs.h_nr_running == 1)) {
>               if ((check_cpu_capacity(env->src_rq, sd)) &&
>                   (capacity_of(env->src_cpu)*sd->imbalance_pct < capacity_of(env->dst_cpu)*100))
> -			return 1;
> +			return true;
>       }
>
>       if (env->migration_type == migrate_misfit)
> -		return 1;
> +		return true;
>
> -	return 0;
> +	return false;
>  }
>
>  static int need_active_balance(struct lb_env *env)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 11:17 ` Valentin Schneider
@ 2020-05-07 17:28   ` Steven Rostedt
  2020-05-07 17:30     ` Steven Rostedt
  0 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2020-05-07 17:28 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Jason Yan, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, bsegall, mgorman, linux-kernel

On Thu, 07 May 2020 12:17:36 +0100
Valentin Schneider <valentin.schneider@arm.com> wrote:

> On 07/05/20 12:06, Jason Yan wrote:
> > Fix the following coccicheck warning:
> >
> > kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
> > 'voluntary_active_balance' with return type bool
> >  
> 
> It's perfectly safe to return 0/1 in a boolean function; that said seeing
> as this is the second attempt at "fixing" this I'm tempted to say we should
> pick it up...
> 

Actually, I disagree. We should push back on the check to not warn on 0/1
of boolean. Why is this a warning?

Fixes like this just add noise to the git history.

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 17:28   ` Steven Rostedt
@ 2020-05-07 17:30     ` Steven Rostedt
  2020-05-07 17:52       ` Valentin Schneider
  2020-05-07 17:55       ` Joe Perches
  0 siblings, 2 replies; 13+ messages in thread
From: Steven Rostedt @ 2020-05-07 17:30 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Jason Yan, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, bsegall, mgorman, linux-kernel

On Thu, 7 May 2020 13:28:28 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> > It's perfectly safe to return 0/1 in a boolean function; that said seeing
> > as this is the second attempt at "fixing" this I'm tempted to say we should
> > pick it up...
> >   
> 
> Actually, I disagree. We should push back on the check to not warn on 0/1
> of boolean. Why is this a warning?

If anything, we can teach people to try to understand their fixes, to see
if something is really a fix or not. Blindly accepting changes like this,
is no different than blindly submitting patches because some tool says its
an issue.

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 17:30     ` Steven Rostedt
@ 2020-05-07 17:52       ` Valentin Schneider
  2020-05-07 17:55       ` Joe Perches
  1 sibling, 0 replies; 13+ messages in thread
From: Valentin Schneider @ 2020-05-07 17:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jason Yan, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, bsegall, mgorman, linux-kernel


On 07/05/20 18:30, Steven Rostedt wrote:
> On Thu, 7 May 2020 13:28:28 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
>> > It's perfectly safe to return 0/1 in a boolean function; that said seeing
>> > as this is the second attempt at "fixing" this I'm tempted to say we should
>> > pick it up...
>> >
>>
>> Actually, I disagree. We should push back on the check to not warn on 0/1
>> of boolean. Why is this a warning?
>
> If anything, we can teach people to try to understand their fixes, to see
> if something is really a fix or not. Blindly accepting changes like this,
> is no different than blindly submitting patches because some tool says its
> an issue.
>

I don't disagree. To play devil's advocate, AFAICT that one coccinelle script
is part of the kernel tree, so some folks may think it worth to reduce the
warnings we get from those.

To give my side of things, this one felt a bit like the
"s/borked/broken/" patches that folks send out because they have a
spellcheck linter, i.e. the change is purely cosmetic. But yeah, I suppose
less gunk to go through via git blame is preferable.

> -- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 17:30     ` Steven Rostedt
  2020-05-07 17:52       ` Valentin Schneider
@ 2020-05-07 17:55       ` Joe Perches
  2020-05-07 18:45         ` Steven Rostedt
  1 sibling, 1 reply; 13+ messages in thread
From: Joe Perches @ 2020-05-07 17:55 UTC (permalink / raw)
  To: Steven Rostedt, Valentin Schneider
  Cc: Jason Yan, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, bsegall, mgorman, linux-kernel

On Thu, 2020-05-07 at 13:30 -0400, Steven Rostedt wrote:
> On Thu, 7 May 2020 13:28:28 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > > It's perfectly safe to return 0/1 in a boolean function; that said seeing
> > > as this is the second attempt at "fixing" this I'm tempted to say we should
> > > pick it up...
> > >   
> > 
> > Actually, I disagree. We should push back on the check to not warn on 0/1
> > of boolean. Why is this a warning?
> 
> If anything, we can teach people to try to understand their fixes, to see
> if something is really a fix or not. Blindly accepting changes like this,
> is no different than blindly submitting patches because some tool says its
> an issue.

<shrug>

Most people seem to prefer bool returns with apparent bool constants
even though true and false are enumerator constants (int) of 1 and 0
in the kernel.

from include/linux/stddef.h:

enum {
	false	= 0,
	true	= 1
};



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 17:55       ` Joe Perches
@ 2020-05-07 18:45         ` Steven Rostedt
  2020-05-07 19:06           ` Joe Perches
  0 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2020-05-07 18:45 UTC (permalink / raw)
  To: Joe Perches
  Cc: Valentin Schneider, Jason Yan, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	linux-kernel

On Thu, 07 May 2020 10:55:33 -0700
Joe Perches <joe@perches.com> wrote:

> > If anything, we can teach people to try to understand their fixes, to see
> > if something is really a fix or not. Blindly accepting changes like this,
> > is no different than blindly submitting patches because some tool says its
> > an issue.  
> 
> <shrug>
> 
> Most people seem to prefer bool returns with apparent bool constants
> even though true and false are enumerator constants (int) of 1 and 0
> in the kernel.
> 
> from include/linux/stddef.h:
> 
> enum {
> 	false	= 0,
> 	true	= 1
> };

Sure, do that for new code, but we don't need these patches popping up for
current code. That is, it's a preference not a bug.

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 18:45         ` Steven Rostedt
@ 2020-05-07 19:06           ` Joe Perches
  2020-05-07 19:45             ` Steven Rostedt
  0 siblings, 1 reply; 13+ messages in thread
From: Joe Perches @ 2020-05-07 19:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Valentin Schneider, Jason Yan, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	linux-kernel

On Thu, 2020-05-07 at 14:45 -0400, Steven Rostedt wrote:
> On Thu, 07 May 2020 10:55:33 -0700
> Joe Perches <joe@perches.com> wrote:
> 
> > > If anything, we can teach people to try to understand their fixes, to see
> > > if something is really a fix or not. Blindly accepting changes like this,
> > > is no different than blindly submitting patches because some tool says its
> > > an issue.  
> > 
> > <shrug>
> > 
> > Most people seem to prefer bool returns with apparent bool constants
> > even though true and false are enumerator constants (int) of 1 and 0
> > in the kernel.
> > 
> > from include/linux/stddef.h:
> > 
> > enum {
> > 	false	= 0,
> > 	true	= 1
> > };
> 
> Sure, do that for new code, but we don't need these patches popping up for
> current code. That is, it's a preference not a bug.

People describe changes as a "fix" all the time for stuff
that isn't an actual fix for a logic defect but is instead
an update to a particular style preference.

Then the "fix" word causes the patch to be rather uselessly
applied to stable trees by AUTOSEL.

It's especially bad when the 'Fixes: <sha1> ("description")'
tag is also added.

It's a difficult thing to regulate and I don't believe a
good mechanism would be possible to add to checkpatch or
coccinelle to help isolate these things.

git diff -w sometimes helps, but that's not really a thing
that checkpatch could do.

Any suggestions?



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 19:06           ` Joe Perches
@ 2020-05-07 19:45             ` Steven Rostedt
  2020-05-07 20:18               ` Joe Perches
  0 siblings, 1 reply; 13+ messages in thread
From: Steven Rostedt @ 2020-05-07 19:45 UTC (permalink / raw)
  To: Joe Perches
  Cc: Valentin Schneider, Jason Yan, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	linux-kernel

On Thu, 07 May 2020 12:06:56 -0700
Joe Perches <joe@perches.com> wrote:

> People describe changes as a "fix" all the time for stuff
> that isn't an actual fix for a logic defect but is instead
> an update to a particular style preference.
> 
> Then the "fix" word causes the patch to be rather uselessly
> applied to stable trees by AUTOSEL.
> 
> It's especially bad when the 'Fixes: <sha1> ("description")'
> tag is also added.
> 
> It's a difficult thing to regulate and I don't believe a
> good mechanism would be possible to add to checkpatch or
> coccinelle to help isolate these things.
> 
> git diff -w sometimes helps, but that's not really a thing
> that checkpatch could do.
> 
> Any suggestions?

I'm unfamiliar with how the coccinelle script is used, but I thought there
was some discussion some time back to have checkpatch not produces the same
kinds of warnings to code as it does to patches.

A lot of useless updates were being submitted when people were running
checkpatch on existing kernel code and producing warnings that are not
worth "fixing", but something that new code should try to avoid.

Basically, I'm fine with a warning that tells you that 1/0 is used for
boolean on code being submitted, but we really shouldn't be encouraging
people to change the code that currently exists with such updates.

-- Steve

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 19:45             ` Steven Rostedt
@ 2020-05-07 20:18               ` Joe Perches
  0 siblings, 0 replies; 13+ messages in thread
From: Joe Perches @ 2020-05-07 20:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Valentin Schneider, Jason Yan, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, bsegall, mgorman,
	linux-kernel

On Thu, 2020-05-07 at 15:45 -0400, Steven Rostedt wrote:
> On Thu, 07 May 2020 12:06:56 -0700
> Joe Perches <joe@perches.com> wrote:
> 
> > People describe changes as a "fix" all the time for stuff
> > that isn't an actual fix for a logic defect but is instead
> > an update to a particular style preference.
> > 
> > Then the "fix" word causes the patch to be rather uselessly
> > applied to stable trees by AUTOSEL.
> > 
> > It's especially bad when the 'Fixes: <sha1> ("description")'
> > tag is also added.
> > 
> > It's a difficult thing to regulate and I don't believe a
> > good mechanism would be possible to add to checkpatch or
> > coccinelle to help isolate these things.
> > 
> > git diff -w sometimes helps, but that's not really a thing
> > that checkpatch could do.
> > 
> > Any suggestions?
> 
> I'm unfamiliar with how the coccinelle script is used, but I thought there
> was some discussion some time back to have checkpatch not produces the same
> kinds of warnings to code as it does to patches.
> 
> A lot of useless updates were being submitted when people were running
> checkpatch on existing kernel code and producing warnings that are not
> worth "fixing", but something that new code should try to avoid.

checkpatch already has several blocks that look like

	if (input_is_a_patch)
		warn(...)
	else if (input_is_a_file)
		check(...)

where by default, check() is not output.

I've also suggested variations discouraging checkpatch
use on files outside of drivers/staging/ multiple times

https://lore.kernel.org/lkml/0753cae7829b98998ac3f5f9fcb52ba1f2475ee1.camel@perches.com/



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-07 11:06 [PATCH] sched/fair: Return true,false in voluntary_active_balance() Jason Yan
  2020-05-07 11:17 ` Valentin Schneider
@ 2020-05-08  8:16 ` Peter Zijlstra
  2020-05-08  9:06   ` Rasmus Villemoes
  2020-05-08  9:24   ` Julia Lawall
  1 sibling, 2 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-05-08  8:16 UTC (permalink / raw)
  To: Jason Yan
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, linux-kernel, linux, Julia.Lawall

On Thu, May 07, 2020 at 07:06:25PM +0800, Jason Yan wrote:
> Fix the following coccicheck warning:
> 
> kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
> 'voluntary_active_balance' with return type bool

That's not a warning, that's a broken cocinelle script, which if these
stupid patches don't stop, I'm going to delete myself!



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-08  8:16 ` Peter Zijlstra
@ 2020-05-08  9:06   ` Rasmus Villemoes
  2020-05-08  9:24   ` Julia Lawall
  1 sibling, 0 replies; 13+ messages in thread
From: Rasmus Villemoes @ 2020-05-08  9:06 UTC (permalink / raw)
  To: Peter Zijlstra, Jason Yan
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, linux-kernel, Julia.Lawall

On 08/05/2020 10.16, Peter Zijlstra wrote:
> On Thu, May 07, 2020 at 07:06:25PM +0800, Jason Yan wrote:
>> Fix the following coccicheck warning:
>>
>> kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
>> 'voluntary_active_balance' with return type bool
> 
> That's not a warning, that's a broken cocinelle script, which if these
> stupid patches don't stop, I'm going to delete myself!


I was wondering why I got cc'ed here. Then it dawned on me. What can I
say, I was young.

Ack on nuking it.

Rasmus


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] sched/fair: Return true,false in voluntary_active_balance()
  2020-05-08  8:16 ` Peter Zijlstra
  2020-05-08  9:06   ` Rasmus Villemoes
@ 2020-05-08  9:24   ` Julia Lawall
  1 sibling, 0 replies; 13+ messages in thread
From: Julia Lawall @ 2020-05-08  9:24 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Jason Yan, mingo, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, linux-kernel, linux, Julia.Lawall



On Fri, 8 May 2020, Peter Zijlstra wrote:

> On Thu, May 07, 2020 at 07:06:25PM +0800, Jason Yan wrote:
> > Fix the following coccicheck warning:
> >
> > kernel/sched/fair.c:9375:9-10: WARNING: return of 0/1 in function
> > 'voluntary_active_balance' with return type bool
>
> That's not a warning, that's a broken cocinelle script, which if these
> stupid patches don't stop, I'm going to delete myself!

Peter,

If you don't like the script, please feel free to delete it.

Currently, no one is really maintaining (ie pushing patches to Linus) the
scripts directory.  Masahiro Yamada was doing it but has expressed several
times that he doesn't want to.  I got a kernel.org account, but clearly
haven't had time to figure out how to use it appropriately.  But simply
deleting a file is simple and risk free, so if you want to make the
change please go ahead.

julia

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-05-08  9:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 11:06 [PATCH] sched/fair: Return true,false in voluntary_active_balance() Jason Yan
2020-05-07 11:17 ` Valentin Schneider
2020-05-07 17:28   ` Steven Rostedt
2020-05-07 17:30     ` Steven Rostedt
2020-05-07 17:52       ` Valentin Schneider
2020-05-07 17:55       ` Joe Perches
2020-05-07 18:45         ` Steven Rostedt
2020-05-07 19:06           ` Joe Perches
2020-05-07 19:45             ` Steven Rostedt
2020-05-07 20:18               ` Joe Perches
2020-05-08  8:16 ` Peter Zijlstra
2020-05-08  9:06   ` Rasmus Villemoes
2020-05-08  9:24   ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).