Skip to contentSkip to conversation

sched: Use proper type for runqueue's idle_at_tick.

PATCH In review Rakib Mullick 3 participants 4 messages Apr 29, 2011 – May 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: Use proper type for runqueue's idle_at_tick.

Searching over scheduler code for uses of idle_at_tick, tells that its been used for making TRUE/FALSE decision. But, its been declared as 'unsigned char', using 'bool' is more rational here. So, for consistency use 'bool' as idle_at_tick type instead of 'unsigned char'.

---

kernel/sched.c +1 -1
index 8cb0a57..d9f7f98 100644
@@ -505,7 +505,7 @@ struct rq {
 
 	unsigned long cpu_power;
 
-	unsigned char idle_at_tick;
+	bool idle_at_tick;
 	/* For active balancing */
 	int post_schedule;
 	int active_balance;
#1 lore raw

[tip:sched/core] sched: Use bool type for rq->idle_at_tick

Commit-ID:  eea502ffd4aeef233b5eadbde405a9df92d57a5e
Gitweb:     http://git.kernel.org/tip/eea502ffd4aeef233b5eadbde405a9df92d57a5e
Author:     Rakib Mullick <[email protected]>
AuthorDate: Sat, 30 Apr 2011 00:01:02 +0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 30 Apr 2011 00:17:14 +0200

sched: Use bool type for rq->idle_at_tick

Searching over the scheduler code for uses of rq->idle_at_tick shows us that it's used for making TRUE/FALSE decision.

Still its type is 'unsigned char' so using 'bool' would be cleaner.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
index f11a2a5..a492209 100644
@@ -505,7 +505,7 @@ struct rq {
 
 	unsigned long cpu_power;
 
-	unsigned char idle_at_tick;
+	bool idle_at_tick;
 	/* For active balancing */
 	int post_schedule;
 	int active_balance;
#2 lore raw

Re: [tip:sched/core] sched: Use bool type for rq->idle_at_tick

Quoted 28 lines · tip-bot for Rakib Mullick
Commit-ID:  eea502ffd4aeef233b5eadbde405a9df92d57a5e
Gitweb:     http://git.kernel.org/tip/eea502ffd4aeef233b5eadbde405a9df92d57a5e
Author:     Rakib Mullick <[email protected]>
AuthorDate: Sat, 30 Apr 2011 00:01:02 +0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 30 Apr 2011 00:17:14 +0200

sched: Use bool type for rq->idle_at_tick

Searching over the scheduler code for uses of rq->idle_at_tick shows us that it's used for making TRUE/FALSE decision.

Still its type is 'unsigned char' so using 'bool' would be cleaner.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +0 -0
index f11a2a5..a492209 100644

kernel/sched.c struct rq { · line 511

Quoted 8 lines
kernel/sched.c +1 -1
@@ -505,7 +505,7 @@ struct rq {
 
 	unsigned long cpu_power;
 
-	unsigned char idle_at_tick;
+	bool idle_at_tick;
 	/* For active balancing */
 	int post_schedule;
 	int active_balance;

Right, so the problem I have with using bool in structures is that sizeof(_Bool) is not well defined by the C standard and is implementation dependent, meaning the struct rq layout can change between gcc versions, architectures or even between optimization levels.

So for structures where the layout is relevant we must avoid bool.

#3 lore raw

Re: [tip:sched/core] sched: Use bool type for rq->idle_at_tick

Quoted 43 lines · Peter Zijlstra
Quoted 28 lines · tip-bot for Rakib Mullick
Commit-ID:  eea502ffd4aeef233b5eadbde405a9df92d57a5e
Gitweb:     http://git.kernel.org/tip/eea502ffd4aeef233b5eadbde405a9df92d57a5e
Author:     Rakib Mullick <[email protected]>
AuthorDate: Sat, 30 Apr 2011 00:01:02 +0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 30 Apr 2011 00:17:14 +0200

sched: Use bool type for rq->idle_at_tick

Searching over the scheduler code for uses of rq->idle_at_tick shows us that it's used for making TRUE/FALSE decision.

Still its type is 'unsigned char' so using 'bool' would be cleaner.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +0 -0
index f11a2a5..a492209 100644

kernel/sched.c struct rq { · line 511

Quoted 8 lines
kernel/sched.c +1 -1
@@ -505,7 +505,7 @@ struct rq {
 
 	unsigned long cpu_power;
 
-	unsigned char idle_at_tick;
+	bool idle_at_tick;
 	/* For active balancing */
 	int post_schedule;
 	int active_balance;

Right, so the problem I have with using bool in structures is that sizeof(_Bool) is not well defined by the C standard and is implementation dependent, meaning the struct rq layout can change between gcc versions, architectures or even between optimization levels.

Quoted 1 line

So for structures where the layout is relevant we must avoid bool.

Okay, zapped it stays then.

Thanks,

Ingo