lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <34572fee-36d0-36e1-ba6d-f098b145aba4@gmx.de>
Date:   Fri, 20 Apr 2018 18:29:07 +0200
From:   Philipp Klocke <Phil_K97@....de>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     lukas.bulwahn@...il.com, kernelnewbies@...nelnewbies.org,
        llvmlinux@...ts.linuxfoundation.org, sil2review@...ts.osadl.org,
        der.herr@...r.at, Ingo Molnar <mingo@...hat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/fair: Change sched_feat(x) in !CONFIG_SCHED_DEBUG
 case

On 20.04.2018 09:57, Peter Zijlstra wrote:

> On Mon, Apr 16, 2018 at 10:54:26AM +0200, Philipp Klocke wrote:
>
>> This patch is motivated by the clang warning Wconstant-logical-operand,
>> issued when logically comparing a variable to a constant integer that is
>> neither 1 nor 0.  It happens for sched_feat(x) when sysctl_sched_features
>> is constant, i.e., CONFIG_SCHED_DEBUG is not set.
>>
>> kernel/sched/fair.c:3927:14: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
>>         if (initial && sched_feat(START_DEBIT))
>>                     ^  ~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/sched/fair.c:3927:14: note: use '&' for a bitwise operation
>>         if (initial && sched_feat(START_DEBIT))
>>                     ^~
>>                     &
>> kernel/sched/fair.c:3927:14: note: remove constant to silence this warning
>>         if (initial && sched_feat(START_DEBIT))
>>                    ~^~~~~~~~~~~~~~~~~~~~~~~~~~
>> @@ -1305,7 +1305,11 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =
>>  	0;
>>  #undef SCHED_FEAT
>>  
>> +#ifdef CONFIG_SCHED_DEBUG
>>  #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
>> +#else
>> +#define sched_feat(x) ((sysctl_sched_features >> __SCHED_FEAT_##x) & 1UL)
>> +#endif
> So this is extra ugly, for no gain?
The gain is stopping a warning that clutters the output log of clang.
To improve readability, one can drop the ifdef-structure and just keep
the right shift version, like Nicholas suggested. This will have a (very
small)
impact on performance in CONFIG_SCHED_DEBUG case, but when
debugging, performance is no problem anyways.
> WTH does clang complain about a constant? Can't you just disable that
> stupid warning?
There are 2 ways to disable the warning. Either disable it for this
particular
occurrence, which clutters the code with #pragma's. THIS is really ugly.
Or disable it globally and maybe miss some important/helpful warnings.
> Also, if sysctl_sched_features is a constant, the both expressions
> _should_ really result in a constant and clang should still warn about
> it.
No, because clang only warns if the constant is neither 1 nor 0.
(These being the 'best' integer representations of booleans)
> I'm really not seeing why we'd want to do this. Just fix clang to not be
> stupid.
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ