From: Denis Efremov <efremov@linux.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Michal Marek <michal.lkml@markovi.net>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Nicolas Palix <nicolas.palix@imag.fr>,
linux-kernel@vger.kernel.org,
Markus Elfring <Markus.Elfring@web.de>,
Joe Perches <joe@perches.com>,
cocci@systeme.lip6.fr
Subject: Re: [Cocci] [PATCH v2] scripts: coccinelle: check for !(un)?likely usage
Date: Fri, 30 Aug 2019 09:56:26 +0300 [thread overview]
Message-ID: <7933d51f-5c2e-26a4-2dee-e13e61d0ac8c@linux.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1908300842060.2184@hadrien>
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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
WARNING: multiple messages have this Message-ID (diff)
From: Denis Efremov <efremov@linux.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
Michal Marek <michal.lkml@markovi.net>,
Markus Elfring <Markus.Elfring@web.de>,
Joe Perches <joe@perches.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: Re: [PATCH v2] scripts: coccinelle: check for !(un)?likely usage
Date: Fri, 30 Aug 2019 09:56:26 +0300 [thread overview]
Message-ID: <7933d51f-5c2e-26a4-2dee-e13e61d0ac8c@linux.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1908300842060.2184@hadrien>
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
next prev parent reply other threads:[~2019-08-30 6:56 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 13:05 [Cocci] [PATCH] scripts: coccinelle: check for !(un)?likely usage Denis Efremov
2019-08-25 13:05 ` Denis Efremov
2019-08-25 15:30 ` [Cocci] " Markus Elfring
2019-08-25 15:30 ` Markus Elfring
2019-08-25 21:06 ` [Cocci] " Denis Efremov
2019-08-25 21:06 ` Denis Efremov
2019-08-25 15:30 ` [Cocci] " Markus Elfring
2019-08-25 15:30 ` Markus Elfring
2019-08-25 16:37 ` [Cocci] " Joe Perches
2019-08-25 16:37 ` Joe Perches
2019-08-25 18:59 ` [Cocci] " Denis Efremov
2019-08-25 18:59 ` Denis Efremov
2019-08-25 19:19 ` [Cocci] " Julia Lawall
2019-08-25 19:19 ` Julia Lawall
2019-08-28 11:33 ` [Cocci] " Rasmus Villemoes
2019-08-28 11:33 ` Rasmus Villemoes
2019-08-28 11:59 ` [Cocci] " Joe Perches
2019-08-28 11:59 ` Joe Perches
2019-08-28 12:33 ` [Cocci] " Denis Efremov
2019-08-28 12:33 ` Denis Efremov
2019-08-28 13:05 ` Rasmus Villemoes
2019-08-28 13:14 ` Denis Efremov
2019-08-28 12:33 ` [Cocci] " Julia Lawall
2019-08-28 12:33 ` Julia Lawall
2019-08-28 12:41 ` [Cocci] " Denis Efremov
2019-08-28 12:41 ` Denis Efremov
2019-08-28 13:57 ` [Cocci] " Denis Efremov
2019-08-28 13:57 ` Denis Efremov
2019-08-25 21:19 ` [Cocci] " Denis Efremov
2019-08-25 21:19 ` Denis Efremov
2019-09-01 17:24 ` Pavel Machek
2019-09-01 17:39 ` [Cocci] " Denis Efremov
2019-09-01 17:39 ` Denis Efremov
2019-08-29 17:10 ` [Cocci] [PATCH v2] " Denis Efremov
2019-08-29 17:10 ` Denis Efremov
2019-08-29 17:13 ` [Cocci] " Denis Efremov
2019-08-29 17:13 ` Denis Efremov
2019-08-30 0:42 ` [Cocci] " Julia Lawall
2019-08-30 0:42 ` Julia Lawall
2019-08-30 6:56 ` Denis Efremov [this message]
2019-08-30 6:56 ` Denis Efremov
2019-08-30 8:06 ` [Cocci] " Rasmus Villemoes
2019-08-30 8:06 ` Rasmus Villemoes
2019-08-29 20:07 ` [Cocci] " Markus Elfring
2019-08-29 20:07 ` Markus Elfring
2019-08-30 7:55 ` [Cocci] " Markus Elfring
2019-08-30 7:55 ` Markus Elfring
2019-08-30 7:55 ` Markus Elfring
2019-09-06 20:19 ` [Cocci] " Julia Lawall
2019-09-06 20:19 ` Julia Lawall
2019-09-06 20:55 ` [Cocci] " Denis Efremov
2019-09-06 20:55 ` Denis Efremov
2019-09-07 8:05 ` [Cocci] [v2] " Markus Elfring
2019-09-07 8:05 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7933d51f-5c2e-26a4-2dee-e13e61d0ac8c@linux.com \
--to=efremov@linux.com \
--cc=Markus.Elfring@web.de \
--cc=cocci@systeme.lip6.fr \
--cc=joe@perches.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=michal.lkml@markovi.net \
--cc=nicolas.palix@imag.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.