All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Khatri, Sunil" <sukhatri@amd.com>,
	Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
	Sunil Khatri <sunil.khatri@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Subject: Re: [PATCH v3 1/4] drm: add function drm_file_err to print proc information too
Date: Wed, 16 Apr 2025 13:22:44 +0200	[thread overview]
Message-ID: <4c41cd5c-db65-4de4-bcc8-4d3e80998af3@amd.com> (raw)
In-Reply-To: <2047d128-5c3a-4f9f-a55d-3188fe7ea3c3@amd.com>

Am 16.04.25 um 10:39 schrieb Khatri, Sunil:
>
> On 4/16/2025 12:37 PM, Tvrtko Ursulin wrote:
>>
>> On 15/04/2025 19:43, Sunil Khatri wrote:
>>> [SNIP]
>>> +
>>
>> I was hoping something primitive could be enough. With no temporary stack space required. Primitive on the level of (but simplified for illustration purpose):
>>
>> #define some_err(_file, _fmt, ...) \
>>     drm_err(dev, "client-%s: " _fmt, (_this)->client_name, ##__VA_ARGS__)
> I also thought of doing it similarly but that dint work. There was lot of code to get the process name and pid along with client_name too. So ##__VA_ARGS__ dont work as soon as its a function and not macro.
> Also drm_err gave me errors and this is the way i find it not complaining. new_fmt is a string directly anymore and hence need to %s to pass but then the drm_err complain too many args for args to pass. So i have to combine new_fmt and args in one to get final_fmt and atleast functionally it worked.
>
> Yesterday even i though that i would be as simple as adding a macro.

It's a bit tricky, but I think that is doable.

You need something like this here:

#define drm_file_err(file, fmt, ...)
    do {
        struct task_struct *task = drm_file_lock_pid(file);

        drm_err(file->dev, "task: %s pid: %d client: %s" fmt, task, file->pid, ##__VA_ARGS_);
        drm_file_unlock_pid(file);
    } while (0);

You then just need to implement drm_file_lock_pid (maybe come up with a better name) to grab the mutex and take the RCU read lock.

Christian.

>>
>> Am I missing something or that would work?
>>
>> Regards,
>>
>> Tvrtko
>>
>>>   void drm_file_update_pid(struct drm_file *);
>>>     struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
>>


      reply	other threads:[~2025-04-16 11:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 18:43 [PATCH v3 1/4] drm: add function drm_file_err to print proc information too Sunil Khatri
2025-04-15 18:43 ` [PATCH v3 2/4] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
2025-04-16  7:29   ` Tvrtko Ursulin
2025-04-16  8:42     ` Khatri, Sunil
2025-04-15 18:43 ` [PATCH v3 3/4] drm/amdgpu: use drm_file_err in logging to also dump process information Sunil Khatri
2025-04-16  7:26   ` Tvrtko Ursulin
2025-04-16 10:01     ` Khatri, Sunil
2025-04-16 12:07       ` Pierre-Eric Pelloux-Prayer
2025-04-16 12:16         ` Khatri, Sunil
2025-04-15 18:43 ` [PATCH v3 4/4] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c Sunil Khatri
2025-04-16  7:18   ` Tvrtko Ursulin
2025-04-16  7:22     ` Khatri, Sunil
2025-04-16  7:07 ` [PATCH v3 1/4] drm: add function drm_file_err to print proc information too Tvrtko Ursulin
2025-04-16  8:39   ` Khatri, Sunil
2025-04-16 11:22     ` Christian König [this message]

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=4c41cd5c-db65-4de4-bcc8-4d3e80998af3@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=sukhatri@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.