From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: bertrand.marquis@arm.com, Rahul.Singh@arm.com,
Julien Grall <jgrall@amazon.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen: Rework WARN_ON() to return whether a warning was triggered
Date: Tue, 15 Dec 2020 13:19:33 +0000 [thread overview]
Message-ID: <04455739-f07f-3da8-f764-33600a9cab6f@xen.org> (raw)
In-Reply-To: <c5ac88e6-4e06-553d-2996-d2b027acd782@suse.com>
Hi,
On 15/12/2020 11:46, Jan Beulich wrote:
> On 15.12.2020 12:26, Julien Grall wrote:
>> --- a/xen/include/xen/lib.h
>> +++ b/xen/include/xen/lib.h
>> @@ -23,7 +23,13 @@
>> #include <asm/bug.h>
>>
>> #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0)
>> -#define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0)
>> +#define WARN_ON(p) ({ \
>> + bool __ret_warn_on = (p); \
>
> Please can you avoid leading underscores here?
I can.
>
>> + \
>> + if ( unlikely(__ret_warn_on) ) \
>> + WARN(); \
>> + unlikely(__ret_warn_on); \
>> +})
>
> Is this latter unlikely() having any effect? So far I thought it
> would need to be immediately inside a control construct or be an
> operand to && or ||.
The unlikely() is directly taken from the Linux implementation.
My guess is the compiler is still able to use the information for the
branch prediction in the case of:
if ( WARN_ON(...) )
Cheers,
> Jan
>
--
Julien Grall
next prev parent reply other threads:[~2020-12-15 13:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 11:26 [PATCH] xen: Rework WARN_ON() to return whether a warning was triggered Julien Grall
2020-12-15 11:31 ` Jürgen Groß
2020-12-15 13:11 ` Julien Grall
2020-12-15 16:20 ` Jürgen Groß
2020-12-17 17:58 ` Bertrand Marquis
2020-12-15 11:46 ` Jan Beulich
2020-12-15 13:19 ` Julien Grall [this message]
2020-12-15 14:01 ` Jan Beulich
2020-12-17 23:54 ` Stefano Stabellini
2020-12-18 0:29 ` Julien Grall
2020-12-18 7:54 ` Jan Beulich
2020-12-18 8:19 ` Jürgen Groß
2020-12-18 8:31 ` Jan Beulich
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=04455739-f07f-3da8-f764-33600a9cab6f@xen.org \
--to=julien@xen.org \
--cc=Rahul.Singh@arm.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=jgrall@amazon.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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.