dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Steven Price <steven.price@arm.com>,
	Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Emily.Deng@amd.com, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, Christian.Koenig@amd.com
Subject: Re: [PATCH v3 1/2] drm/sched: Avoid job cleanup if sched thread is parked.
Date: Tue, 26 Nov 2019 10:08:35 +0100	[thread overview]
Message-ID: <c75aff45-2fc6-47da-34e0-a179f1ce5e9a@gmail.com> (raw)
In-Reply-To: <93c692cb-5306-e024-57f1-463402cb2c44@arm.com>

Am 25.11.19 um 17:51 schrieb Steven Price:
> On 25/11/2019 14:10, Andrey Grodzovsky wrote:
>> When the sched thread is parked we assume ring_mirror_list is
>> not accessed from here.
> FWIW I don't think this is necessary. kthread_park() will wait until the
> thread is parked, at which point the thread is stuck in kthread_parkme()
> until unparked.
>
> So all this does is avoid waiting for any cleanup jobs before parking -
> which might be a reasonable goal in itself, but if so lets at least
> document that.

Now that you mention it that is indeed wrong.

The real problem is that in the main thread we mangled the call to 
kthread_parkme() into drm_sched_blocked() which can be called in atomic 
context.

I suggest to rework this so that the kthread_should_park() and 
kthread_should_stop() test in wait_event_interruptible() come first and 
then call kthread_parkme() outside of the wait_event_interruptible().

Regards,
Christian.

>
> Steve
>
>> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/scheduler/sched_main.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
>> index d4cc728..6774955 100644
>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>> @@ -635,9 +635,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
>>   	struct drm_sched_job *job;
>>   	unsigned long flags;
>>   
>> -	/* Don't destroy jobs while the timeout worker is running */
>> -	if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
>> -	    !cancel_delayed_work(&sched->work_tdr))
>> +	/*
>> +	* Don't destroy jobs while the timeout worker is running  OR thread
>> +	* is being parked and hence assumed to not touch ring_mirror_list
>> +	*/
>> +	if ((sched->timeout != MAX_SCHEDULE_TIMEOUT &&
>> +	     !cancel_delayed_work(&sched->work_tdr)) ||
>> +	     __kthread_should_park(sched->thread))
>>   		return NULL;
>>   
>>   	spin_lock_irqsave(&sched->job_list_lock, flags);
>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-11-26  9:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 14:10 [PATCH v3 1/2] drm/sched: Avoid job cleanup if sched thread is parked Andrey Grodzovsky
2019-11-25 14:10 ` Andrey Grodzovsky
2019-11-25 14:10 ` [PATCH v3 2/2] drm/scheduler: Avoid accessing freed bad job Andrey Grodzovsky
2019-11-25 14:10   ` Andrey Grodzovsky
     [not found]   ` <1574691041-5499-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2019-11-25 16:57     ` Steven Price
2019-11-25 16:57       ` Steven Price
2019-11-25 16:51 ` [PATCH v3 1/2] drm/sched: Avoid job cleanup if sched thread is parked Steven Price
2019-11-26  9:08   ` Christian König [this message]
2019-11-26 15:36     ` Andrey Grodzovsky
2019-11-27 15:32       ` Andrey Grodzovsky
     [not found]         ` <b3835ff0-15f0-ead4-0255-3d93fc560c77-5C7GfCeVMHo@public.gmane.org>
2019-11-27 15:35           ` Christian König
2019-11-27 15:35             ` 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=c75aff45-2fc6-47da-34e0-a179f1ce5e9a@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Emily.Deng@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrey.grodzovsky@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=steven.price@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox