All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy <nirmodas@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Nirmoy Das" <nirmoy.aiemd@gmail.com>,
	alexander.deucher@amd.com, kenny.ho@amd.com
Cc: nirmoy.das@amd.com, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/scheduler: do not keep a copy of sched list
Date: Tue, 10 Dec 2019 15:47:46 +0100	[thread overview]
Message-ID: <97343695-4b6d-1dfb-2c52-e728a7f1736e@amd.com> (raw)
In-Reply-To: <800c29bf-11dd-0ac9-32ad-ef3476f07643@amd.com>


On 12/10/19 2:00 PM, Christian König wrote:
> Am 10.12.19 um 13:53 schrieb Nirmoy Das:
>> entity should not keep copy and maintain sched list for
>> itself.
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>> ---
>>   drivers/gpu/drm/scheduler/sched_entity.c | 10 +---------
>>   1 file changed, 1 insertion(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
>> b/drivers/gpu/drm/scheduler/sched_entity.c
>> index f9b6ce29c58f..a5f729f421f8 100644
>> --- a/drivers/gpu/drm/scheduler/sched_entity.c
>> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
>> @@ -67,17 +67,10 @@ int drm_sched_entity_init(struct drm_sched_entity 
>> *entity,
>>       entity->guilty = guilty;
>>       entity->num_sched_list = num_sched_list;
>>       entity->priority = priority;
>> -    entity->sched_list =  kcalloc(num_sched_list,
>> -                      sizeof(struct drm_gpu_scheduler *), GFP_KERNEL);
>> +    entity->sched_list =  sched_list;
>
> Maybe make this "num_sched_list > 1 ? sched_list : NULL" to avoid 
> accidentally dereferencing a stale pointer to the stack.
Do you mean "num_sched_list >= 1 ? sched_list : NULL"
>
>>   -    if(!entity->sched_list)
>> -        return -ENOMEM;
>>         init_completion(&entity->entity_idle);
>> -
>> -    for (i = 0; i < num_sched_list; i++)
>> -        entity->sched_list[i] = sched_list[i];
>> -
>>       if (num_sched_list)
>
> That check can actually be dropped as well. We return -EINVAL when the 
> num_sched_list is zero.

This  one took me some time to understand. So we don't really return 
-EINVAL if num_sched_list == 0

if (!(entity && sched_list && (num_sched_list == 0 || sched_list[0])))
                 return -EINVAL;

This is coming from below patch. Are we suppose to tolerate IPs with 
uninitialized sched so that ctx creation dosn't return error ?

commit 1decbf6bb0b4dc56c9da6c5e57b994ebfc2be3aa
Author: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Date:   Wed Jan 30 02:53:19 2019 +0100

     drm/sched: Fix entities with 0 rqs.

     Some blocks in amdgpu can have 0 rqs.

     Job creation already fails with -ENOENT when entity->rq is NULL,
     so jobs cannot be pushed. Without a rq there is no scheduler to
     pop jobs, and rq selection already does the right thing with a
     list of length 0.

     So the operations we need to fix are:
       - Creation, do not set rq to rq_list[0] if the list can have 
length 0.
       - Do not flush any jobs when there is no rq.
       - On entity destruction handle the rq = NULL case.
       - on set_priority, do not try to change the rq if it is NULL.

>
> Regards,
> Christian.
>
>>           entity->rq = 
>> &entity->sched_list[0]->sched_rq[entity->priority];
>>   @@ -312,7 +305,6 @@ void drm_sched_entity_fini(struct 
>> drm_sched_entity *entity)
>>         dma_fence_put(entity->last_scheduled);
>>       entity->last_scheduled = NULL;
>> -    kfree(entity->sched_list);
>>   }
>>   EXPORT_SYMBOL(drm_sched_entity_fini);
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-12-10 14:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10 12:52 [PATCH 1/4] drm/scheduler: rework entity creation Nirmoy Das
2019-12-10 12:52 ` [PATCH 2/4] drm/amdgpu: replace vm_pte's run-queue list with drm gpu scheds list Nirmoy Das
2019-12-10 12:52 ` [PATCH 3/4 v2] amd/amdgpu: add sched array to IPs with multiple run-queues Nirmoy Das
2019-12-10 12:57   ` Christian König
2019-12-10 12:53 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-10 13:00   ` Christian König
2019-12-10 13:02     ` Christian König
2019-12-10 14:47     ` Nirmoy [this message]
2019-12-10 15:08       ` Nirmoy
2019-12-10 17:32         ` Christian König
2019-12-10 18:38           ` Nirmoy
  -- strict thread matches above, loose matches on Subject: below --
2019-12-11 15:42 [PATCH 1/4] drm/scheduler: rework entity creation Nirmoy Das
2019-12-11 15:42 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-11 15:42   ` Nirmoy Das
2019-12-11 14:24 [PATCH 1/4 v2] drm/scheduler: rework entity creation Nirmoy Das
2019-12-11 14:24 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-10 18:17 [PATCH 1/4] drm/scheduler: rework entity creation Nirmoy Das
2019-12-10 18:17 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-11 12:25   ` Christian König
2019-12-09 21:53 [PATCH 1/4] drm/scheduler: rework entity creation Nirmoy Das
2019-12-09 21:53 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-06 17:33 [PATCH 1/4] drm/scheduler: rework entity creation Nirmoy Das
2019-12-06 17:33 ` [PATCH 4/4] drm/scheduler: do not keep a copy of sched list Nirmoy Das
2019-12-06 19:41   ` Christian König
2019-12-08 19:57     ` Nirmoy
2019-12-09 12:20       ` Christian König
2019-12-09 13:56         ` Nirmoy
2019-12-09 14:09           ` Nirmoy
2019-12-09 15:37             ` 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=97343695-4b6d-1dfb-2c52-e728a7f1736e@amd.com \
    --to=nirmodas@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=kenny.ho@amd.com \
    --cc=nirmoy.aiemd@gmail.com \
    --cc=nirmoy.das@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.