sched: Make sched_feat(x) boolean for !CONFIG_SCHED_DEBUG
PATCH 1/1 sched: Make sched_feat(x) boolean for !CONFIG_SCHED_DEBUG
If scheduler debugging is disabled sched_feat() resolves to a constant value that can be non-boolean. clang raises a warning when it detects that a non-boolean constant is used as operand in logical expressions:
kernel/sched/core.c:208:26: warning: use of logical '&&' with constant
operand [-Wconstant-logical-operand]
if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~Convert the original expression to boolean by means of a double not operation.
--- kernel/sched/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/sched.h +1 -1
@@ -1393,7 +1393,7 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =0 ;#undef SCHED_FEAT -#define sched_feat (x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) +#define sched_feat (x) (!!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x)))#endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */
Signature · 1 line
2.19.1.568.g152ad8e336-goog
Quoted 10 lines · Matthias Kaehlcke
If scheduler debugging is disabled
sched_feat()resolves to a constant value that can be non-boolean. clang raises a warning when it detects that a non-boolean constant is used as operand in logical expressions:
kernel/sched/core.c:208:26: warning: use of logical '&&' with constant
operand [-Wconstant-logical-operand]if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY)) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Convert the original expression to boolean by means of a double not operation.
Reported-by Philipp Klocke <[email protected]>Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Matthias Kaehlcke <[email protected]>
Thanks for resending, but I'm tracking this patch in -next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=7e6f4c5d600c1c8e2a1d900e65cab319d9b6782e
I just cloned -next yesterday and looks like it's still there.
Quoted 20 lines
--- kernel/sched/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/sched.h +1
-2@@ -1393,7 +1393,7 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =0 ;#undef SCHED_FEAT -#define sched_feat (x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) +#define sched_feat (x) (!!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x)))#endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */ --2.19.1.568.g152ad8e336-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers