From: Jani Nikula <jani.nikula@linux.intel.com>
To: Sunil Khatri <sunil.khatri@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
"Pierre-Eric Pelloux-Prayer" <pierre-eric.pelloux-prayer@amd.com>,
"Sunil Khatri" <sunil.khatri@amd.com>
Subject: Re: [PATCH v4 1/5] drm: add macro drm_file_err to print process info
Date: Wed, 16 Apr 2025 17:25:06 +0300 [thread overview]
Message-ID: <87lds0p4jh.fsf@intel.com> (raw)
In-Reply-To: <20250416133144.862023-1-sunil.khatri@amd.com>
On Wed, 16 Apr 2025, Sunil Khatri <sunil.khatri@amd.com> wrote:
> Add a drm helper macro which append the process information for
> the drm_file over drm_err.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
> include/drm/drm_file.h | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 94d365b22505..5ae5ad1048fb 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -37,6 +37,7 @@
> #include <uapi/drm/drm.h>
>
> #include <drm/drm_prime.h>
> +#include <drm/drm_print.h>
Not a fan of including drm_print.h everywhere that drm_file.h is
included. We've been trying to get rid of this, and go the other
way. It's really hard to manage dependencies when everything ends up
including everything.
>
> struct dma_fence;
> struct drm_file;
> @@ -446,6 +447,46 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
> return file_priv->minor->type == DRM_MINOR_ACCEL;
> }
>
> +static struct task_struct *drm_task_lock(struct drm_file *file_priv)
> + __attribute__((__maybe_unused));
inline is the keyword you're missing here, and that's why you've had to
add maybe unused...
> +static struct task_struct *drm_task_lock(struct drm_file *file_priv)
> +{
> + struct task_struct *task;
> + struct pid *pid;
> +
> + mutex_lock(&file_priv->client_name_lock);
> + rcu_read_lock();
> + pid = rcu_dereference(file_priv->pid);
> + task = pid_task(pid, PIDTYPE_TGID);
> + return task;
> +}
> +
> +static void drm_task_unlock(struct drm_file *file_priv) __attribute__((__maybe_unused));
> +static void drm_task_unlock(struct drm_file *file_priv)
> +{
> + rcu_read_unlock();
> + mutex_unlock(&file_priv->client_name_lock);
> +}
...but *why* are you inlining these? To make this header self-contained,
I think you'd need to add maybe sched.h, pid.h, rcupdate.h, mutex.h, or
something. I consider static inlines actively harmful if they force you
to pull in a lot of other headers.
> +/**
> + * drm_file_err - Fill info string with process name and pid
> + * @file_priv: context of interest for process name and pid
> + * @fmt: prinf() like format string
> + *
> + * This update the user provided buffer with process
> + * name and pid information for @file_priv
> + */
> +#define drm_file_err(file_priv, fmt, ...) \
> + do { \
> + struct task_struct *task; \
> + struct drm_device *dev = file_priv->minor->dev; \
> + \
> + task = drm_task_lock(file_priv); \
> + drm_err(dev, "comm: %s pid: %d client: %s " fmt, \
> + task ? task->comm : "", task ? task->pid : 0, \
> + file_priv->client_name ?: "Unset", ##__VA_ARGS__); \
> + drm_task_unlock(file_priv); \
> + } while (0)
> +
For that matter, why is *this* inline? For debugs it makes a little more
sense when it adds the function, but drm_err() doesn't.
Make all of these real functions, no need to include drm_print.h, and
everything is better.
BR,
Jani.
> void drm_file_update_pid(struct drm_file *);
>
> struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-04-16 14:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 13:31 [PATCH v4 1/5] drm: add macro drm_file_err to print process info Sunil Khatri
2025-04-16 13:31 ` [PATCH v4 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
2025-04-16 13:31 ` [PATCH v4 3/5] drm/amdgpu: use drm_file_err to add process info Sunil Khatri
2025-04-16 13:31 ` [PATCH v4 4/5] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c Sunil Khatri
2025-04-16 13:31 ` [PATCH v4 5/5] drm/amdgpu: change DRM_DBG_DRIVER to drm_dbg_driver Sunil Khatri
2025-04-16 14:25 ` Jani Nikula [this message]
2025-04-16 14:55 ` [PATCH v4 1/5] drm: add macro drm_file_err to print process info Khatri, Sunil
2025-04-17 9:12 ` Khatri, Sunil
2025-04-17 11:13 ` 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=87lds0p4jh.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=sunil.khatri@amd.com \
--cc=tvrtko.ursulin@igalia.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.