From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3] drm/xe: Remove unwanted mutex locking
Date: Wed, 29 May 2024 17:59:52 -0400 [thread overview]
Message-ID: <ZlelWCyAEtS2hUjW@intel.com> (raw)
In-Reply-To: <20240529213925.22239-1-niranjana.vishwanathapura@intel.com>
On Wed, May 29, 2024 at 02:39:25PM -0700, Niranjana Vishwanathapura wrote:
> Do not hold xef->exec_queue.lock mutex while parsing the xarray
> xef->exec_queue.xa in xe_file_close() as it is not needed and
> will cause an unwanted dependency between this lock and the vm->lock.
>
> This lock protects the exec queue lookup and reference taking which
> doesn't apply to this code path. When FD is closing, IOCTLs presumably
> can't be modifying the xarray.
>
> v2: Update commit text (Matt Brost)
> v3: Add more code comment (Rodrigo Vivi)
>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> Reviewed-by: Jagmeet Randhawa <jagmeet.randhawa@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index f04b11e45c2d..bf4c4306f6d3 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -96,12 +96,15 @@ static void xe_file_close(struct drm_device *dev, struct drm_file *file)
> struct xe_exec_queue *q;
> unsigned long idx;
>
> - mutex_lock(&xef->exec_queue.lock);
> + /*
> + * No need for exec_queue.lock here as there is no contention at
> + * this point.
I'm really sorry to be pedantic here. "But why is there no contention at this point?"
This remain unanswered here in the comment, and only a further code inspection or
a git-blame archeology would lead to the commit message with:
"When FD is closing, IOCTLs presumably can't be modifying the xarray."
> Taking exec_queue.lock here causes undue dependency
> + * on vm->lock taken during xe_exec_queue_kill().
> + */
> xa_for_each(&xef->exec_queue.xa, idx, q) {
> xe_exec_queue_kill(q);
> xe_exec_queue_put(q);
> }
> - mutex_unlock(&xef->exec_queue.lock);
> xa_destroy(&xef->exec_queue.xa);
> mutex_destroy(&xef->exec_queue.lock);
> mutex_lock(&xef->vm.lock);
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-05-29 22:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 21:39 [PATCH v3] drm/xe: Remove unwanted mutex locking Niranjana Vishwanathapura
2024-05-29 21:45 ` ✓ CI.Patch_applied: success for drm/xe: Remove unwanted mutex locking (rev3) Patchwork
2024-05-29 21:45 ` ✓ CI.checkpatch: " Patchwork
2024-05-29 21:46 ` ✓ CI.KUnit: " Patchwork
2024-05-29 21:58 ` ✓ CI.Build: " Patchwork
2024-05-29 21:58 ` ✗ CI.Hooks: failure " Patchwork
2024-05-29 21:59 ` Rodrigo Vivi [this message]
2024-05-29 21:59 ` ✓ CI.checksparse: success " Patchwork
2024-05-29 22:32 ` ✓ CI.BAT: " Patchwork
2024-05-30 1:26 ` ✓ CI.FULL: " Patchwork
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=ZlelWCyAEtS2hUjW@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=niranjana.vishwanathapura@intel.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.