From: Felix Kuehling <felix.kuehling@amd.com>
To: William Palacek <William.Palacek@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Harish.Kasiviswanathan@amd.com, christian.koenig@amd.com,
philip.yang@amd.com
Subject: Re: [PATCH 2/4] drm/amdkfd: don't take p->mutex in AMDKFD_IOC_GET_CLOCK_COUNTERS
Date: Fri, 20 Nov 2026 16:35:49 -0500 [thread overview]
Message-ID: <a33a538c-865d-415d-be37-e516e60b21be@amd.com> (raw)
In-Reply-To: <459bad3a225aa415fa359d638046f8cd7d26b0ab.1795014593.git.William.Palacek@amd.com>
On 2026-11-18 10:10, William Palacek wrote:
> The ioctl takes p->mutex only to look up the pdd. p->pdds[] is filled
> in create_process() before the process is published and freed only at
> teardown, and the clock read that follows already uses the pdd without
> the lock, so the lock protects nothing.
That's not completely true. kfd_process_device_data_by_id compares the
gpu_id with pdd->user_gpu_id, which is updated under the p->mutex by
criu_restore.
Regards,
Felix
>
> It does serialize every clock counter query of the process behind
> whatever holds p->mutex. Threads submitting GPU work call this ioctl
> (seen in a PyTorch workload on MI300X), so while one thread registered
> and mapped a 32 GiB userptr, the others waited in it (205 ms measured
> for one call).
>
> Signed-off-by: William Palacek <William.Palacek@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 3d2136adb62b..9886bbd28ea2 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -745,9 +745,8 @@ static int kfd_ioctl_get_clock_counters(struct file *filep,
> struct kfd_ioctl_get_clock_counters_args *args = data;
> struct kfd_process_device *pdd;
>
> - mutex_lock(&p->mutex);
> + /* p->pdds[] is fixed from process creation to teardown, no lock needed */
> pdd = kfd_process_device_data_by_id(p, args->gpu_id);
> - mutex_unlock(&p->mutex);
> if (pdd)
> /* Reading GPU clock counter from KGD */
> args->gpu_clock_counter = amdgpu_amdkfd_get_gpu_clock_counter(pdd->dev->adev);
next prev parent reply other threads:[~2026-11-20 21:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:10 [PATCH 0/4] drm/amdkfd: don't stall other threads during large userptr registration William Palacek
2026-11-18 15:10 ` [PATCH 1/4] drm/amdgpu: limit userptr sg segments to half of sg->length William Palacek
2026-11-20 21:28 ` Felix Kuehling
2026-11-18 15:10 ` [PATCH 2/4] drm/amdkfd: don't take p->mutex in AMDKFD_IOC_GET_CLOCK_COUNTERS William Palacek
2026-11-20 21:35 ` Felix Kuehling [this message]
2026-11-18 15:10 ` [PATCH 3/4] drm/amdgpu: drop mmap_lock between chunks when faulting userptr pages William Palacek
2026-11-20 21:48 ` Felix Kuehling
2026-11-18 15:10 ` [PATCH 4/4] drm/amdkfd: register userptr pages without holding KFD process locks William Palacek
2026-11-19 14:26 ` [PATCH 0/4] drm/amdkfd: don't stall other threads during large userptr registration Christian König
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=a33a538c-865d-415d-be37-e516e60b21be@amd.com \
--to=felix.kuehling@amd.com \
--cc=Harish.Kasiviswanathan@amd.com \
--cc=William.Palacek@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=philip.yang@amd.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.