All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"Roper, Matthew D" <matthew.d.roper@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [Intel-xe] [RFC 4/5] drm/xe: Remove useless XE_BUG_ON.
Date: Wed, 29 Mar 2023 12:31:01 +0300	[thread overview]
Message-ID: <87o7ob52ga.fsf@intel.com> (raw)
In-Reply-To: <09b3de5d-4b8a-bf41-5e18-c583958b39b1@intel.com>

On Tue, 28 Mar 2023, Michal Wajdeczko <michal.wajdeczko@intel.com> wrote:
> On 28.03.2023 22:27, Vivi, Rodrigo wrote:
>> On Tue, 2023-03-28 at 13:24 -0700, Matt Roper wrote:
>>> On Tue, Mar 28, 2023 at 12:10:20PM -0400, Rodrigo Vivi wrote:
>>>> If that becomes needed for some reason we bring it
>>>> back with some written reasoning.
>>>
>>> From a quick skim through this patch, most/all of these shouldn't be
>>> BUG_ON either.  These are assertions that we don't expect to get
>>> triggered, but if we do screw up somewhere we shouldn't be bringing
>>> down
>>> the entire machine; a WARN (and possibly an early exit) would be more
>>> appropriate for most of these.
>> 
>> yeap! I fully agree on that. I get frustrated when I hit one of these
>> BUG_ONs that should be a graceful exit with a warn without a panic...
>
> Recently there was another discussion with proposal to introduce
> XE_ASSERT as a replacement of XE_BUG_ON - is this still considered ?
>
> We likely don't want to pollute production driver with too many
> redundant BUG_ON/WARN_ON, but still want be paranoid on debug builds
> (with just WARNs and continuing until the unavoidable crash).

There are a number of related factors here. From least subjective to
most subjective:

First, the trend in kernel is to pretty much never use BUG_ON. The idea
is that you WARN_ON, and it's the userspace policy to set panic_on_warn
to oops. This includes the CI.

Second, each of the macros could use a comment describing what it does,
what it does not, what it should be used for, and what not. Currently
there is zero, neither in xe or i915. Everyone just figures it out for
themselves or cargo-cults.

Third, I think having *BUG_ON/*WARN_ON in the name of a local macro that
behaves differently from the originals is misleading. To this end I
suggested naming it ASSERT something or other to model it after C
standard library assert(3) that generates no code for NDEBUG. IMO it
implies debug build behaviour better than *BUG_ON. I think the current
*BUG_ON/*WARN_ON give a false sense of security regarding input
validation.

(I understand the need for asserts that generate no code for non-debug
builds when the asserts have a performance impact.)

Fourth, I do think the current *BUG_ONs are being used too
liberally. They're everywhere, so more is added everywhere. That's the
example being followed. Shouldn't happen so no harm in adding a check,
right? Well, I'm not so sure about that. There are 1300+ GEM_BUG_ON's
and GEM_WARN_ON's in i915. (Of which only 4 under display, but that's
probably due to the "GEM" naming as well as my opinion of them.)


BR,
Jani.



-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-03-29  9:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 16:10 [Intel-xe] [RFC 0/5] Start killing xe_macros Rodrigo Vivi
2023-03-28 16:10 ` [Intel-xe] [RFC 1/5] !fixup: drm/i915/display: Remaining changes to make xe compile Rodrigo Vivi
2023-03-28 16:10 ` [Intel-xe] [RFC 2/5] !fixup: drm/xe: Allow fbdev to allocate stolen memory Rodrigo Vivi
2023-03-28 16:10 ` [Intel-xe] [RFC 3/5] drm/xe: Remove useless XE_WARN_ON Rodrigo Vivi
2023-03-28 18:26   ` Matthew Brost
2023-03-28 18:58     ` Rodrigo Vivi
2023-03-28 16:10 ` [Intel-xe] [RFC 4/5] drm/xe: Remove useless XE_BUG_ON Rodrigo Vivi
2023-03-28 20:24   ` Matt Roper
2023-03-28 20:27     ` Vivi, Rodrigo
2023-03-28 21:03       ` Michal Wajdeczko
2023-03-29  9:31         ` Jani Nikula [this message]
2023-03-29 19:25           ` Rodrigo Vivi
2023-03-28 16:10 ` [Intel-xe] [RFC 5/5] drm/xe/xe_macro: Remove unused stuff Rodrigo Vivi
2023-03-28 16:16 ` [Intel-xe] ✓ CI.Patch_applied: success for Start killing xe_macros Patchwork
2023-03-28 16:17 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-03-28 16:21 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-03-28 16:43 ` [Intel-xe] ○ CI.BAT: info " Patchwork

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=87o7ob52ga.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=rodrigo.vivi@intel.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.