All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Sunil Khatri <sunil.khatri@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	"Pelloux-prayer,
	Pierre-eric" <Pierre-eric.Pelloux-prayer@amd.com>,
	Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v1 1/3] drm: function to get process name and pid
Date: Mon, 14 Apr 2025 19:58:09 +0200	[thread overview]
Message-ID: <c2ef0925-14ad-4eff-9972-53406ec01f0a@gmail.com> (raw)
In-Reply-To: <20250411130428.4104957-1-sunil.khatri@amd.com>

Adding Pierre-eric and Tvrtko as well.

Am 11.04.25 um 15:04 schrieb Sunil Khatri:
> Add helper function which get the process information for
> the drm_file and updates the user provided character buffer
> with the information of process name and pid as a string.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
>  drivers/gpu/drm/drm_file.c | 30 ++++++++++++++++++++++++++++++
>  include/drm/drm_file.h     |  1 +
>  2 files changed, 31 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index cb5f22f5bbb6..4434258d21b5 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -965,6 +965,36 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>  }
>  EXPORT_SYMBOL(drm_show_fdinfo);
>  
> +/**
> + * drm_process_info - Fill info string with process name and pid
> + * @file_priv: context of interest for process name and pid
> + * @proc_info: user char ptr to write the string to
> + * @buff_size: size of the buffer passed for the string
> + *
> + * This update the user provided buffer with process
> + * name and pid information for @file_priv
> + */
> +void drm_process_info(struct drm_file *file_priv, char *proc_info, size_t buff_size)
> +{
> +	struct task_struct *task;
> +	struct pid *pid;
> +	struct drm_device *dev = file_priv->minor->dev;
> +
> +	if (!proc_info) {
> +		drm_err(dev, "Invalid user buffer\n");
> +		return;
> +	}
> +
> +	rcu_read_lock();
> +	pid = rcu_dereference(file_priv->pid);
> +	task = pid_task(pid, PIDTYPE_TGID);
> +	if (task)
> +		snprintf(proc_info, buff_size, "comm:%s pid:%d", task->comm, task->pid);

Looks good in general, but I think people would like to see the optional client name here as well.

It's rather useful to have for native context.

Regards,
Christian.

> +
> +	rcu_read_unlock();
> +}
> +EXPORT_SYMBOL(drm_process_info);
> +
>  /**
>   * mock_drm_getfile - Create a new struct file for the drm device
>   * @minor: drm minor to wrap (e.g. #drm_device.primary)
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index f0ef32e9fa5e..c01b34936968 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -501,6 +501,7 @@ void drm_print_memory_stats(struct drm_printer *p,
>  
>  void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file);
>  void drm_show_fdinfo(struct seq_file *m, struct file *f);
> +void drm_process_info(struct drm_file *file_priv, char *proc_info, size_t buff_size);
>  
>  struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags);
>  


  parent reply	other threads:[~2025-04-14 17:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 13:04 [PATCH v1 1/3] drm: function to get process name and pid Sunil Khatri
2025-04-11 13:04 ` [PATCH v1 2/3] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
2025-04-11 13:04 ` [PATCH v1 3/3] drm/amdgpu: update the error logging for more information Sunil Khatri
2025-04-11 14:24   ` Alex Deucher
2025-04-11 16:01     ` Khatri, Sunil
2025-04-14  6:55 ` [PATCH v1 1/3] drm: function to get process name and pid Khatri, Sunil
2025-04-14 17:58 ` Christian König [this message]
2025-04-15  8:44   ` Tvrtko Ursulin
2025-04-15 10:07     ` Khatri, Sunil

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=c2ef0925-14ad-4eff-9972-53406ec01f0a@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Pierre-eric.Pelloux-prayer@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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.