The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: daniel@ffwll.ch, 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: Tue, 19 Jan 2021 10:46:53 +0100	[thread overview]
Message-ID: <019f2342-9d64-f6c6-d03d-0ab8ddce101d@gmail.com> (raw)
In-Reply-To: <YAan6haGjnIlNIoJ@hirez.programming.kicks-ass.net>

Am 19.01.21 um 10:35 schrieb Peter Zijlstra:
> On Mon, Jan 18, 2021 at 07:03:34PM +0100, Christian König wrote:
>
>> 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
>> +	 * trivial deadlock with page faults for example. Make lockdep complain
>> +	 * about it early on.
>> +	 */
> Egads, the cursed comment style is spreading :/
>
>> +	if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
>> +		lockdep_assert_none_held_once();
>> +
> Should this not be part of drm_syncobj_fence_add_wait() instead?

drm_syncobj_fence_add_wait() is only called when the previous try of 
finding the fence wasn't successfully.

If we want to check drivers for stupid behavior for the uncommon wait 
before signal case we need this much earlier.

But I'm going to double check if drm_syncobj_fence_add_wait() isn't used 
elsewhere as well.

> Also, do you want to sprinkle might_sleep() around ?

Good point. Going to add that as well.

Thanks,
Christian.

>
>>   	*fence = drm_syncobj_fence_get(syncobj);
>>   	drm_syncobj_put(syncobj);
>>   
>> diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h


  reply	other threads:[~2021-01-19 10:12 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
2021-01-19  9:35   ` Peter Zijlstra
2021-01-19  9:46     ` Christian König [this message]
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=019f2342-9d64-f6c6-d03d-0ab8ddce101d@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=christian.koenig@amd.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