The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	daniel@ffwll.ch, peterz@infradead.org, mingo@redhat.com,
	will@kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/syncobj: make lockdep complain on WAIT_FOR_SUBMIT v2
Date: Mon, 18 Jan 2021 11:42:06 -0800	[thread overview]
Message-ID: <3ebc7345-1b3f-8e7f-dc12-eacfd3a993d9@infradead.org> (raw)
In-Reply-To: <20210118180334.43714-2-christian.koenig@amd.com>

Hi,

Just a comment about the comments:

On 1/18/21 10:03 AM, Christian König wrote:
> DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT can't be used when we hold locks
> since we are basically waiting for userspace to do something.
> 
> Holding a lock while doing so can trivial deadlock with page faults
> etc...
> 
> So make lockdep complain when a driver tries to do this.
> 
> v2: Add lockdep_assert_none_held() macro.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/drm_syncobj.c | 7 +++++++
>  include/linux/lockdep.h       | 5 +++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 6e74e6745eca..f51458615158 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -387,6 +387,13 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
>  	if (!syncobj)
>  		return -ENOENT;
>  
> +	/* Waiting for userspace with locks help is illegal cause that can

	                                    held            because

> +	 * trivial deadlock with page faults for example. Make lockdep complain

	   trivially

> +	 * about it early on.
> +	 */
> +	if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
> +		lockdep_assert_none_held_once();
> +
>  	*fence = drm_syncobj_fence_get(syncobj);
>  	drm_syncobj_put(syncobj);
>  


thanks.
-- 
~Randy
You can't do anything without having to do something else first.
-- Belefant's Law

  reply	other threads:[~2021-01-18 19:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 18:03 Let lockdep complain when locks are taken while waiting for userspace Christian König
2021-01-18 18:03 ` [PATCH] drm/syncobj: make lockdep complain on WAIT_FOR_SUBMIT v2 Christian König
2021-01-18 19:42   ` Randy Dunlap [this message]
2021-01-19  9:35   ` Peter Zijlstra
2021-01-19  9:46     ` Christian König
2021-01-19 10:05       ` Peter Zijlstra
2021-01-19 10:08         ` 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=3ebc7345-1b3f-8e7f-dc12-eacfd3a993d9@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox