New sparse warnings from sched.h
commit 799ba82de01e7543f6b2042e1a739f3a20255f23
Author: luca abeni <[email protected]> Date: Thu Sep 7 12:09:31 2017 +0200
sched/deadline: Use C bitfields for the state flags
Ask the compiler to use a single bit for storing true / false values, instead of wasting the size of a whole int value.
Tested with gcc 5.4.0 on x86_64, and the compiler produces the expected Assembly (similar to the Assembly code generated when explicitly accessing the bits with bitmasks, "&" and "|").
produces four warnings from sparse for every file which includes sched.h:
./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield ./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield ./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield ./include/linux/sched.h:479:62: error: dubious one-bit signed bitfield
This seems like the trivial fix (untested):
include/linux/sched.h +4 -4
@@ -473,10 +473,10 @@ struct sched_dl_entity {* conditions between the inactive timer handler and the wakeup * code. */ - int dl_throttled : 1; - int dl_boosted : 1; - int dl_yielded : 1; - int dl_non_contending : 1; + unsigned int dl_throttled : 1; + unsigned int dl_boosted : 1; + unsigned int dl_yielded : 1; + unsigned int dl_non_contending : 1;/* * Bandwidth enforcement timer. Each -deadline task has its
Quoted 32 lines · Matthew Wilcox
commit
799ba82de01e7543f6b2042e1a739f3a20255f23Author: luca abeni <[email protected]> Date: Thu Sep 7 12:09:31 2017 +0200sched/deadline: Use C bitfields for the state flags
Ask the compiler to use a single bit for storing true / false values, instead of wasting the size of a whole int value.
Tested with gcc 5.4.0 onx86_64, and the compiler produces the expected Assembly (similar to the Assembly code generated when explicitly accessing the bits with bitmasks, "&" and "|").produces four warnings from sparse for every file which includes
sched.h:
./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield./include/linux/sched.h:479:62: error: dubious one-bit signed bitfieldThis seems like the trivial fix (untested):
include/linux/sched.h +0
-1@@ -473,10 +473,10 @@ struct sched_dl_entity {* conditions between the inactive timer handler and the wakeup * code. */ - int dl_throttled : 1;
include/linux/sched.h struct sched_dl_entity { · line 482
Quoted 10 lines
include/linux/sched.h +4
-3- int dl_boosted : 1; - int dl_yielded : 1; - int dl_non_contending : 1; + unsigned int dl_throttled : 1; + unsigned int dl_boosted : 1; + unsigned int dl_yielded : 1; + unsigned int dl_non_contending : 1;/* * Bandwidth enforcement timer. Each -deadline task has its
Mind sending a proper patch with a SOB once it's tested?
Thanks,
Ingo
Quoted 40 lines · Ingo Molnar
Quoted 39 lines · Matthew Wilcox
commit
799ba82de01e7543f6b2042e1a739f3a20255f23Author: luca abeni <[email protected]> Date: Thu Sep 7 12:09:31 2017 +0200sched/deadline: Use C bitfields for the state flags
Ask the compiler to use a single bit for storing true / false values, instead of wasting the size of a whole int value.
Tested with gcc 5.4.0 onx86_64, and the compiler produces the expected Assembly (similar to the Assembly code generated when explicitly accessing the bits with bitmasks, "&" and "|").produces four warnings from sparse for every file which includes
sched.h:
./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield./include/linux/sched.h:479:62: error: dubious one-bit signed bitfieldThis seems like the trivial fix (untested):
include/linux/sched.h +4
-4@@ -473,10 +473,10 @@ struct sched_dl_entity {* conditions between the inactive timer handler and the wakeup * code. */ - int dl_throttled : 1; - int dl_boosted : 1; - int dl_yielded : 1; - int dl_non_contending : 1; + unsigned int dl_throttled : 1; + unsigned int dl_boosted : 1; + unsigned int dl_yielded : 1; + unsigned int dl_non_contending : 1;
Quoted 4 lines
include/linux/sched.h struct sched_dl_entity { · line 482
Quoted 2 lines
include/linux/sched.h +0
-0/* * Bandwidth enforcement timer. Each -deadline task has its Mind sending a proper patch with a SOB once it's tested?
I'd be more than happy to do that. I have no idea what this code is, what it's used for, or how to test it, so I'll have to rely on somebody else to test it.
Quoted 41 lines · Matthew Wilcox
Quoted 40 lines · Ingo Molnar
Quoted 39 lines · Matthew Wilcox
commit
799ba82de01e7543f6b2042e1a739f3a20255f23Author: luca abeni <[email protected]> Date: Thu Sep 7 12:09:31 2017 +0200sched/deadline: Use C bitfields for the state flags
Ask the compiler to use a single bit for storing true / false values, instead of wasting the size of a whole int value.
Tested with gcc 5.4.0 onx86_64, and the compiler produces the expected Assembly (similar to the Assembly code generated when explicitly accessing the bits with bitmasks, "&" and "|").produces four warnings from sparse for every file which includes
sched.h:
./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield./include/linux/sched.h:479:62: error: dubious one-bit signed bitfieldThis seems like the trivial fix (untested):
include/linux/sched.h +4
-4@@ -473,10 +473,10 @@ struct sched_dl_entity {* conditions between the inactive timer handler and the wakeup * code. */ - int dl_throttled : 1; - int dl_boosted : 1; - int dl_yielded : 1; - int dl_non_contending : 1; + unsigned int dl_throttled : 1; + unsigned int dl_boosted : 1; + unsigned int dl_yielded : 1; + unsigned int dl_non_contending : 1;
Quoted 8 lines
Quoted 4 lines
include/linux/sched.h struct sched_dl_entity { · line 482
Quoted 2 lines
include/linux/sched.h +0
-0/* * Bandwidth enforcement timer. Each -deadline task has its Mind sending a proper patch with a SOB once it's tested?
I'd be more than happy to do that. I have no idea what this code is, what it's used for, or how to test it, so I'll have to rely on somebody else to test it.
Oh, I thought you wanted to test whether it fixes the Sparse bug.
Converting these bitfields from signed to unsigned should have no effect on the deadline scheduler.
I.e. I basically only need your Signed-off-by.
Thnaks,
Ingo
Hi,
Quoted 15 lines · On Tue, 14 Nov 2017 12:41:35 -0800 Matthew Wilcox <[email protected]> wrote:
commit
799ba82de01e7543f6b2042e1a739f3a20255f23Author: luca abeni <[email protected]> Date: Thu Sep 7 12:09:31 2017 +0200sched/deadline: Use C bitfields for the state flags
Ask the compiler to use a single bit for storing true / false
values, instead of wasting the size of a whole int value.
Tested with gcc 5.4.0 onx86_64, and the compiler produces the
expected Assembly (similar to the Assembly code generated when explicitly accessing the bits with bitmasks, "&" and "|").produces four warnings from sparse for every file which includes
sched.h:
Quoted 6 lines
./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield./include/linux/sched.h:479:62: error: dubious one-bit signed bitfieldThis seems like the trivial fix (untested):
[...]
I think Dan Carpenter sent a similar patch (and I replied agreeing with it).
I believe in this particular case signed integers are safe, but if "unsigned int" is the preferred style in the kernel I agree with the change.
Thanks,
Luca
Quoted 22 lines
include/linux/sched.h +0
-0@@ -473,10 +473,10 @@ struct sched_dl_entity {* conditions between the inactive timer handler and the wakeup
include/linux/sched.h +4
-4* code. */ - int dl_throttled : 1; - int dl_boosted : 1; - int dl_yielded : 1; - int dl_non_contending : 1; + unsigned int dl_throttled : 1; + unsigned int dl_boosted : 1; + unsigned int dl_yielded : 1; + unsigned int dl_non_contending : 1;/* * Bandwidth enforcement timer. Each -deadline task has its