From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, Sam Ravnborg <sam@ravnborg.org>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RESEND 8/8] drm/print: introduce new struct drm_device based logging macros
Date: Mon, 28 Oct 2019 19:09:37 +0200 [thread overview]
Message-ID: <20191028170937.GS1208@intel.com> (raw)
In-Reply-To: <63d1e72b99e9c13ee5b1b362a653ff9c21e19124.1572258936.git.jani.nikula@intel.com>
On Mon, Oct 28, 2019 at 12:38:22PM +0200, Jani Nikula wrote:
> Add new struct drm_device based logging macros modeled after the core
> kernel device based logging macros. These would be preferred over the
> drm printk and struct device based macros in drm code, where possible.
>
> We have existing drm specific struct device based logging functions, but
> they are too verbose to use for two main reasons:
>
> * The names are unnecessarily long, for example DRM_DEV_DEBUG_KMS().
>
> * The use of struct device over struct drm_device is too generic for
> most users, leading to an extra dereference.
>
> For example:
>
> DRM_DEV_DEBUG_KMS(drm->dev, "Hello, world\n");
>
> vs.
>
> drm_dbg_kms(drm, "Hello, world\n");
>
> It's a matter of taste, but the SHOUTING UPPERCASE has been argued to be
> less readable than lowercase.
>
> Some names are changed from old DRM names to be based on the core kernel
> logging functions. For example, NOTE -> notice, ERROR -> err, DEBUG ->
> dbg.
>
> Due to the conflation of DRM_DEBUG and DRM_DEBUG_DRIVER macro use
> (DRM_DEBUG is used widely in drivers though it's supposed to be a core
> debugging category), they are named as drm_dbg_core and drm_dbg,
> respectively.
>
> The drm_err and _once/_ratelimited variants no longer include the
> function name in order to be able to use the core device based logging
> macros. Arguably this is not a significant change; error messages should
> not be so common to be only distinguishable by the function name.
>
> Ratelimited debug logging macros are to be added later.
>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> With something like this, I think i915 could start migrating to
> drm_device based logging. I have a hard time convincing myself or anyone
> about migrating to the DRM_DEV_* variants.
Looks reasonable enough to me. For the series
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
One thing that still bugs me about drm_dbg() is that the category
check is inside it. So we pay the function call overhead for every
debug statement even when debugging is disabled. So I'd also like
to see a patch moving the category check back into the
macros/static inline (IIRC it was there originally).
> ---
> include/drm/drm_print.h | 65 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
>
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index 085a9685270c..e4040dea0d8c 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -322,6 +322,8 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
>
> /*
> * struct device based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> */
>
> __printf(3, 4)
> @@ -417,8 +419,71 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
> _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_PRIME, \
> fmt, ##__VA_ARGS__)
>
> +/*
> + * struct drm_device based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> + */
> +
> +/* Helper for struct drm_device based logging. */
> +#define __drm_printk(drm, level, type, fmt, ...) \
> + dev_##level##type(drm->dev, "[drm] " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_info(drm, fmt, ...) \
> + __drm_printk(drm, info,, fmt, ##__VA_ARGS__)
> +
> +#define drm_notice(drm, fmt, ...) \
> + __drm_printk(drm, notice,, fmt, ##__VA_ARGS__)
> +
> +#define drm_warn(drm, fmt, ...) \
> + __drm_printk(drm, warn,, fmt, ##__VA_ARGS__)
> +
> +#define drm_err(drm, fmt, ...) \
> + __drm_printk(drm, err,, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_info_once(drm, fmt, ...) \
> + __drm_printk(drm, info, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_notice_once(drm, fmt, ...) \
> + __drm_printk(drm, notice, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_warn_once(drm, fmt, ...) \
> + __drm_printk(drm, warn, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_err_once(drm, fmt, ...) \
> + __drm_printk(drm, err, _once, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_err_ratelimited(drm, fmt, ...) \
> + __drm_printk(drm, err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_dbg_core(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_CORE, fmt, ##__VA_ARGS__)
> +#define drm_dbg(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
> +#define drm_dbg_kms(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_KMS, fmt, ##__VA_ARGS__)
> +#define drm_dbg_prime(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
> +#define drm_dbg_atomic(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
> +#define drm_dbg_vbl(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_VBL, fmt, ##__VA_ARGS__)
> +#define drm_dbg_state(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_STATE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_lease(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_dp(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_DP, fmt, ##__VA_ARGS__)
> +
> +
> /*
> * printk based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> */
>
> __printf(2, 3)
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, Sam Ravnborg <sam@ravnborg.org>,
dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH RESEND 8/8] drm/print: introduce new struct drm_device based logging macros
Date: Mon, 28 Oct 2019 19:09:37 +0200 [thread overview]
Message-ID: <20191028170937.GS1208@intel.com> (raw)
Message-ID: <20191028170937.FjYWEg-kIuN9sIPdTxMIg7T1ooSpDgJM0f14NpZ-TLg@z> (raw)
In-Reply-To: <63d1e72b99e9c13ee5b1b362a653ff9c21e19124.1572258936.git.jani.nikula@intel.com>
On Mon, Oct 28, 2019 at 12:38:22PM +0200, Jani Nikula wrote:
> Add new struct drm_device based logging macros modeled after the core
> kernel device based logging macros. These would be preferred over the
> drm printk and struct device based macros in drm code, where possible.
>
> We have existing drm specific struct device based logging functions, but
> they are too verbose to use for two main reasons:
>
> * The names are unnecessarily long, for example DRM_DEV_DEBUG_KMS().
>
> * The use of struct device over struct drm_device is too generic for
> most users, leading to an extra dereference.
>
> For example:
>
> DRM_DEV_DEBUG_KMS(drm->dev, "Hello, world\n");
>
> vs.
>
> drm_dbg_kms(drm, "Hello, world\n");
>
> It's a matter of taste, but the SHOUTING UPPERCASE has been argued to be
> less readable than lowercase.
>
> Some names are changed from old DRM names to be based on the core kernel
> logging functions. For example, NOTE -> notice, ERROR -> err, DEBUG ->
> dbg.
>
> Due to the conflation of DRM_DEBUG and DRM_DEBUG_DRIVER macro use
> (DRM_DEBUG is used widely in drivers though it's supposed to be a core
> debugging category), they are named as drm_dbg_core and drm_dbg,
> respectively.
>
> The drm_err and _once/_ratelimited variants no longer include the
> function name in order to be able to use the core device based logging
> macros. Arguably this is not a significant change; error messages should
> not be so common to be only distinguishable by the function name.
>
> Ratelimited debug logging macros are to be added later.
>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> With something like this, I think i915 could start migrating to
> drm_device based logging. I have a hard time convincing myself or anyone
> about migrating to the DRM_DEV_* variants.
Looks reasonable enough to me. For the series
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
One thing that still bugs me about drm_dbg() is that the category
check is inside it. So we pay the function call overhead for every
debug statement even when debugging is disabled. So I'd also like
to see a patch moving the category check back into the
macros/static inline (IIRC it was there originally).
> ---
> include/drm/drm_print.h | 65 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
>
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index 085a9685270c..e4040dea0d8c 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -322,6 +322,8 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
>
> /*
> * struct device based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> */
>
> __printf(3, 4)
> @@ -417,8 +419,71 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
> _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_PRIME, \
> fmt, ##__VA_ARGS__)
>
> +/*
> + * struct drm_device based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> + */
> +
> +/* Helper for struct drm_device based logging. */
> +#define __drm_printk(drm, level, type, fmt, ...) \
> + dev_##level##type(drm->dev, "[drm] " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_info(drm, fmt, ...) \
> + __drm_printk(drm, info,, fmt, ##__VA_ARGS__)
> +
> +#define drm_notice(drm, fmt, ...) \
> + __drm_printk(drm, notice,, fmt, ##__VA_ARGS__)
> +
> +#define drm_warn(drm, fmt, ...) \
> + __drm_printk(drm, warn,, fmt, ##__VA_ARGS__)
> +
> +#define drm_err(drm, fmt, ...) \
> + __drm_printk(drm, err,, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_info_once(drm, fmt, ...) \
> + __drm_printk(drm, info, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_notice_once(drm, fmt, ...) \
> + __drm_printk(drm, notice, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_warn_once(drm, fmt, ...) \
> + __drm_printk(drm, warn, _once, fmt, ##__VA_ARGS__)
> +
> +#define drm_err_once(drm, fmt, ...) \
> + __drm_printk(drm, err, _once, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_err_ratelimited(drm, fmt, ...) \
> + __drm_printk(drm, err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__)
> +
> +
> +#define drm_dbg_core(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_CORE, fmt, ##__VA_ARGS__)
> +#define drm_dbg(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
> +#define drm_dbg_kms(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_KMS, fmt, ##__VA_ARGS__)
> +#define drm_dbg_prime(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
> +#define drm_dbg_atomic(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
> +#define drm_dbg_vbl(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_VBL, fmt, ##__VA_ARGS__)
> +#define drm_dbg_state(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_STATE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_lease(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_dp(drm, fmt, ...) \
> + drm_dev_dbg(drm->dev, DRM_UT_DP, fmt, ##__VA_ARGS__)
> +
> +
> /*
> * printk based logging
> + *
> + * Prefer drm_device based logging over device or prink based logging.
> */
>
> __printf(2, 3)
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-10-28 17:09 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 10:38 [PATCH RESEND 0/8] drm/print: cleanup and new drm_device based logging Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-28 10:38 ` [PATCH RESEND 1/8] drm/i915: use drm_debug_enabled() to check for debug categories Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
[not found] ` <cover.1572258935.git.jani.nikula-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2019-10-28 10:38 ` [PATCH RESEND 2/8] drm/nouveau: " Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-28 10:38 ` [PATCH RESEND 3/8] drm/amdgpu: " Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-28 10:38 ` [PATCH RESEND 4/8] drm/print: rename drm_debug to __drm_debug to discourage use Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-28 10:38 ` [PATCH RESEND 5/8] drm/print: underscore prefix functions that should be private to print Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-11-01 20:16 ` Rodrigo Vivi
2019-11-01 20:16 ` [Intel-gfx] " Rodrigo Vivi
2019-10-28 10:38 ` [PATCH RESEND 6/8] drm/print: convert debug category macros into an enum Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-29 9:02 ` Joonas Lahtinen
2019-10-29 9:02 ` [Intel-gfx] " Joonas Lahtinen
2019-10-29 9:27 ` Jani Nikula
2019-10-29 9:27 ` [Intel-gfx] " Jani Nikula
2019-10-28 10:38 ` [PATCH RESEND 7/8] drm/print: group logging functions by prink or device based Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-11-01 20:25 ` Rodrigo Vivi
2019-11-01 20:25 ` [Intel-gfx] " Rodrigo Vivi
2019-10-28 10:38 ` [PATCH RESEND 8/8] drm/print: introduce new struct drm_device based logging macros Jani Nikula
2019-10-28 10:38 ` [Intel-gfx] " Jani Nikula
2019-10-28 17:09 ` Ville Syrjälä [this message]
2019-10-28 17:09 ` Ville Syrjälä
2019-11-01 20:27 ` Rodrigo Vivi
2019-11-01 20:27 ` [Intel-gfx] " Rodrigo Vivi
2019-10-28 13:28 ` ✗ Fi.CI.CHECKPATCH: warning for drm/print: cleanup and new drm_device based logging (rev2) Patchwork
2019-10-28 13:28 ` [Intel-gfx] " Patchwork
2019-10-28 13:49 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-10-28 13:49 ` [Intel-gfx] " Patchwork
2019-10-28 18:49 ` ✗ Fi.CI.CHECKPATCH: warning for drm/print: cleanup and new drm_device based logging (rev3) Patchwork
2019-10-28 18:49 ` [Intel-gfx] " Patchwork
2019-10-28 19:30 ` ✓ Fi.CI.BAT: success " Patchwork
2019-10-28 19:30 ` [Intel-gfx] " Patchwork
2019-10-29 13:57 ` ✓ Fi.CI.IGT: " Patchwork
2019-10-29 13:57 ` [Intel-gfx] " Patchwork
2019-11-12 15:21 ` [PATCH RESEND 0/8] drm/print: cleanup and new drm_device based logging Sean Paul
2019-11-12 15:21 ` [Intel-gfx] " Sean Paul
2019-11-14 12:27 ` Jani Nikula
2019-11-14 12:27 ` [Intel-gfx] " Jani Nikula
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=20191028170937.GS1208@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=sam@ravnborg.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox