linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]cputime: make bool type for steal ticks
@ 2012-11-16  9:24 liguang
  2013-01-26  0:45 ` Frederic Weisbecker
  0 siblings, 1 reply; 5+ messages in thread
From: liguang @ 2012-11-16  9:24 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, liguang

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 kernel/sched/cputime.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 81b763b..d2c24c1 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -282,7 +282,7 @@ static __always_inline bool steal_account_process_tick(void)
 		this_rq()->prev_steal_time += st * TICK_NSEC;
 
 		account_steal_time(st);
-		return st;
+		return !!st;
 	}
 #endif
 	return false;
-- 
1.7.1


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

* Re: [PATCH]cputime: make bool type for steal ticks
  2012-11-16  9:24 [PATCH]cputime: make bool type for steal ticks liguang
@ 2013-01-26  0:45 ` Frederic Weisbecker
  2013-01-26  1:24   ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2013-01-26  0:45 UTC (permalink / raw)
  To: liguang; +Cc: mingo, peterz, linux-kernel

2012/11/16 liguang <lig.fnst@cn.fujitsu.com>:
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  kernel/sched/cputime.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 81b763b..d2c24c1 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -282,7 +282,7 @@ static __always_inline bool steal_account_process_tick(void)
>                 this_rq()->prev_steal_time += st * TICK_NSEC;
>
>                 account_steal_time(st);
> -               return st;
> +               return !!st;

I would expect gcc to perform the semantic "!!" cast implicitly. I
just did some basic tests locally and it does.
I prefer to be paranoid and not do any assumption though, unless I'm
told gcc always guarantees this correct implicit cast. I'm queuing
this patch and will send it to Ingo.

Thanks!

>         }
>  #endif
>         return false;
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH]cputime: make bool type for steal ticks
  2013-01-26  0:45 ` Frederic Weisbecker
@ 2013-01-26  1:24   ` Joe Perches
  2013-01-26 14:38     ` Frederic Weisbecker
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2013-01-26  1:24 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: liguang, mingo, peterz, linux-kernel

On Sat, 2013-01-26 at 01:45 +0100, Frederic Weisbecker wrote:
> > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
[]
> > @@ -282,7 +282,7 @@ static __always_inline bool steal_account_process_tick(void)
[]
> > -               return st;
> > +               return !!st;
> 
> I would expect gcc to perform the semantic "!!" cast implicitly. I
> just did some basic tests locally and it does.
> I prefer to be paranoid and not do any assumption though, unless I'm
> told gcc always guarantees this correct implicit cast. I'm queuing
> this patch and will send it to Ingo.

It's unnecessary.

6.3.1.2p1:

"When any scalar value is converted to _Bool, the result is 0
if the value compares equal to 0; otherwise, the result is 1."



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

* Re: [PATCH]cputime: make bool type for steal ticks
  2013-01-26  1:24   ` Joe Perches
@ 2013-01-26 14:38     ` Frederic Weisbecker
  0 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2013-01-26 14:38 UTC (permalink / raw)
  To: Joe Perches; +Cc: liguang, mingo, peterz, linux-kernel

2013/1/26 Joe Perches <joe@perches.com>:
> On Sat, 2013-01-26 at 01:45 +0100, Frederic Weisbecker wrote:
>> > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> []
>> > @@ -282,7 +282,7 @@ static __always_inline bool steal_account_process_tick(void)
> []
>> > -               return st;
>> > +               return !!st;
>>
>> I would expect gcc to perform the semantic "!!" cast implicitly. I
>> just did some basic tests locally and it does.
>> I prefer to be paranoid and not do any assumption though, unless I'm
>> told gcc always guarantees this correct implicit cast. I'm queuing
>> this patch and will send it to Ingo.
>
> It's unnecessary.
>
> 6.3.1.2p1:
>
> "When any scalar value is converted to _Bool, the result is 0
> if the value compares equal to 0; otherwise, the result is 1."

Ok then I'll ignore this patch. If somebody oppose, raise your hand.

Thanks.

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

* [PATCH]cputime: make bool type for steal ticks
@ 2012-11-06  7:12 liguang
  0 siblings, 0 replies; 5+ messages in thread
From: liguang @ 2012-11-06  7:12 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, liguang

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 kernel/sched/cputime.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 81b763b..d2c24c1 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -282,7 +282,7 @@ static __always_inline bool steal_account_process_tick(void)
 		this_rq()->prev_steal_time += st * TICK_NSEC;
 
 		account_steal_time(st);
-		return st;
+		return !!st;
 	}
 #endif
 	return false;
-- 
1.7.1


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

end of thread, other threads:[~2013-01-26 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-16  9:24 [PATCH]cputime: make bool type for steal ticks liguang
2013-01-26  0:45 ` Frederic Weisbecker
2013-01-26  1:24   ` Joe Perches
2013-01-26 14:38     ` Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2012-11-06  7:12 liguang

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).