From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>,
Chris Wilson <chris@chris-wilson.co.uk>Daniel Vetter
<daniel@ffwll.ch>, intel-gfx <intel-gfx@lists.freedesktop.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: BUG_ON vs WARN_ON (was: Re: [PATCH] drm/i915: Localise the fbdev console lock frobbing)
Date: Thu, 14 Aug 2014 13:07:06 +0300 [thread overview]
Message-ID: <871tsjqt9x.fsf@intel.com> (raw)
In-Reply-To: <CAKMK7uHcEaHD1T7jRdA24dmjM8UexNC5c8J1oDn2x21yT0C-qw@mail.gmail.com>
On Thu, 14 Aug 2014, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Aug 14, 2014 at 8:54 AM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> I disaggree with the conversion of the BUG_ON though, a WARN there is
>> going to screw up unpredictably (well, a hard hang without any output
>> is the predictable outcome). I'd like to have asserts for things that
>> could and should be statically analyzed...
>
> Well I've put a zero-tolerance rule for BUG_ON into place with the
> only exception if the kernel will die anyway in the next few lines.
> Which means I trade in a limping (and potentially dangerous) kernel
> for the ability to be able to read the backtrace somewhere. I agree
> that any such extreme policy will end up looking stupid in some cases,
> but I've just decided that I wasted too much time on chasing lookups
> which would have been trivial to debug with a WARN_ON instead of a
> BUG_ON.
>
> Until I've wasted too much time with WARN_ON instead of BUG_ON I'll
> let it stick. And it's supported by my patch scripts, so small chance
> I'll miss one. Ofc I'll never change it without a notice in the commit
> message, so people can always blame me for it.
In other words, WARN_ON is the new BUG_ON. But what's the new WARN_ON?
Now we're conflating two things (limp home mode and crashing) into
one. When I see WARN_ON in code, it's no longer clear to me whether this
is a condition that we're supposed to survive or not. For example, does
the code below a WARN_ON need to properly handle errors due to the
condition? To me, BUG_ON is a code reading aide that sets the absolute
precondition for the following code. Something that absolutely must be
fixed if someone hits it, while WARN_ON can sometimes be ignored, or
even replaced with DRM_DEBUG.
If we have zero-tolerance for BUG_ON, and replace all of those with
WARN_ON, we'll need to start being *very* selective about adding WARN_ON
as well.
BR,
Jani.
> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2014-08-14 10:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 14:15 [PATCH] drm/i915: Localise the fbdev console lock frobbing Chris Wilson
2014-08-13 11:26 ` Daniel Vetter
2014-08-13 11:32 ` Chris Wilson
2014-08-13 11:39 ` Daniel Vetter
2014-08-13 12:00 ` Chris Wilson
2014-08-13 12:05 ` Chris Wilson
2014-08-13 12:09 ` Chris Wilson
2014-08-13 12:46 ` Daniel Vetter
2014-08-13 12:58 ` Chris Wilson
2014-08-13 13:04 ` Daniel Vetter
2014-08-13 13:09 ` Chris Wilson
2014-08-13 13:40 ` Daniel Vetter
2014-08-14 6:54 ` Chris Wilson
2014-08-14 8:35 ` Daniel Vetter
2014-08-14 10:07 ` Jani Nikula [this message]
2014-08-14 14:18 ` BUG_ON vs WARN_ON (was: Re: [PATCH] drm/i915: Localise the fbdev console lock frobbing) Daniel Vetter
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=871tsjqt9x.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel@ffwll.ch \
/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.