From: Greg KH <gregkh@linuxfoundation.org>
To: Varsha Rao <rvarsha016@gmail.com>
Cc: outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: Re: [Outreachy kernel] Questions regarding BUG macro.
Date: Fri, 24 Feb 2017 15:48:09 +0100 [thread overview]
Message-ID: <20170224144809.GA8962@kroah.com> (raw)
In-Reply-To: <e34c38a0-18ca-4d80-ba2a-113d74689185@googlegroups.com>
On Fri, Feb 24, 2017 at 04:10:30AM -0800, Varsha Rao wrote:
>
> What is the functionality of unreachable() ?
It tells the compiler that it will never execute this.
> Isn't the do while loop unnecessary in the given definition ?
Not at all, why do you think it would be?
> #define BUG()��� ��� ��� ��� ��� ��� ��� ���
> ��� do {��� ��� ��� ��� ��� ��� ��� ���
> ��� ��� _BUG_OR_WARN(0);��� ��� ��� ��� ���
> ��� ��� unreachable();��� ��� ��� ��� ��� ���
> ��� } while (0)
>
> Found the above definition at staging/arch/avr32/include/asm/bug.h
> Also what is the difference between unreachable() and unlikely()?
unlikely is a hint to the compiler that the statement vare rarely
happens. unreachable tells the compiler that this code will never be
run, due to something stopping the CPU before it can happen.
Never use either of these in your code unless you really know what you
are doing. Never use unlikely() unless you can measure the difference
of it being used and not being used, because almost always humans get it
wrong, CPUs are very good at guessing what should happen.
hope this helps,
greg k-h
next prev parent reply other threads:[~2017-02-24 14:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 12:10 Questions regarding BUG macro Varsha Rao
2017-02-24 14:48 ` Greg KH [this message]
2017-02-24 18:24 ` [Outreachy kernel] " Varsha Rao
2017-02-24 18:29 ` Julia Lawall
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=20170224144809.GA8962@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=outreachy-kernel@googlegroups.com \
--cc=rvarsha016@gmail.com \
/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.