[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7933d51f-5c2e-26a4-2dee-e13e61d0ac8c@linux.com>
Date: Fri, 30 Aug 2019 09:56:26 +0300
From: Denis Efremov <efremov@...ux.com>
To: Julia Lawall <julia.lawall@...6.fr>
Cc: linux-kernel@...r.kernel.org, cocci@...teme.lip6.fr,
Gilles Muller <Gilles.Muller@...6.fr>,
Nicolas Palix <nicolas.palix@...g.fr>,
Michal Marek <michal.lkml@...kovi.net>,
Markus Elfring <Markus.Elfring@....de>,
Joe Perches <joe@...ches.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: Re: [PATCH v2] scripts: coccinelle: check for !(un)?likely usage
On 30.08.2019 03:42, Julia Lawall wrote:
>
>
> On Thu, 29 Aug 2019, Denis Efremov wrote:
>
>> On 8/29/19 8:10 PM, Denis Efremov wrote:
>>> This patch adds coccinelle script for detecting !likely and
>>> !unlikely usage. These notations are confusing. It's better
>>> to replace !likely(x) with unlikely(!x) and !unlikely(x) with
>>> likely(!x) for readability.
>>
>> I'm not sure that this rule deserves the acceptance.
>> Just to want to be sure that "!unlikely(x)" and "!likely(x)"
>> are hard-readable is not only my perception and that they
>> become more clear in form "likely(!x)" and "unlikely(!x)" too.
>
> Is likely/unlikely even useful for anything once it is a subexpression?
>> julia
>
Well, as far as I understand it,
It's correct since it sets the probability of likely/unlikely subexpression
is true to 90% (see https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Other-Builtins.html).
The probability of a whole expression is then computed by GCC
in this case. It's kind of assigning individual weights to conjuncts/disjuncts.
I think that it can be useful when you are not sure about the probability
of the whole expression but you know something about subexpressions it consists, e.g.,
likely(E1) && E2. However, I think that "!unlikely(x)" is fully equivalent in this sense
to "likely(!x)". I tested it once again for allyesconfig with branch profiling
disabled and bloat-o-meter shows no diff in binary size.
Denis
Powered by blists - more mailing lists