All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [Intel-xe] [PATCH v7 1/2] drm/xe/buddy: add visible tracking
Date: Tue, 21 Mar 2023 13:15:52 +0200	[thread overview]
Message-ID: <87fs9y8idz.fsf@intel.com> (raw)
In-Reply-To: <20230321104529.157616-2-matthew.auld@intel.com>

On Tue, 21 Mar 2023, Matthew Auld <matthew.auld@intel.com> wrote:
> +	XE_BUG_ON(min_page_size < mm->chunk_size);
> +	XE_BUG_ON(min_page_size > SZ_2G); /* FIXME: sg limit */
> +	XE_BUG_ON(size > SZ_2G &&
> +		  (vres->base.placement & TTM_PL_FLAG_CONTIGUOUS));
> +	XE_BUG_ON(!IS_ALIGNED(size, min_page_size));

Hijacking the thread, sorry. ;)

If we are supposed to not replicate i915-ism, why do we have
XE_BUG_ON()?

I think it's an anti-pattern.

Currently XE_BUG_ON() is just BUG_ON(), which should not be used for any
reason. Not even CI. The plan in i915 is to migrate all of them to
WARN_ON()'s and use panic_on_warn in CI.

The other thing is that having BUG_ON() in the name gives you the false
impression that it's sufficient for input (or any precondition)
validation. In i915 it gets conditionally built for CI only. So we catch
errors in CI but not in actual production use. You just plunge on.

Part of it is just naming. The BUG_ON() association is pretty strong for
any kernel developers. If it were called XE_ASSERT() it would have an
association with assert() that does what XE_BUG_ON() actually is: code
is only generated for debug builds.

In i915 it has become habitual to sprinkle GEM_BUG_ON() all over the
place, just in case, belt and suspenders. IMO there's not enough
discretion about what can and can't actually happen, and what can and
can't happen in CI vs. production.


BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-03-21 11:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 10:45 [Intel-xe] [PATCH v7 0/2] Some small-bar prep patches Matthew Auld
2023-03-21 10:45 ` [Intel-xe] [PATCH v7 1/2] drm/xe/buddy: add visible tracking Matthew Auld
2023-03-21 11:15   ` Jani Nikula [this message]
2023-03-21 11:24     ` Matthew Auld
2023-03-21 11:32       ` Jani Nikula
2023-03-21 10:45 ` [Intel-xe] [PATCH v7 2/2] drm/xe/buddy: add compatible and intersects hooks Matthew Auld
2023-03-21 10:48 ` [Intel-xe] ✓ CI.Patch_applied: success for Some small-bar prep patches (rev7) Patchwork
2023-03-21 10:49 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-03-21 10:53 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-03-21 11:05 ` [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=87fs9y8idz.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.auld@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.