dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: matthew.brost@intel.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, faith@gfxstrand.net,
	luben.tuikov@amd.com, Danilo Krummrich <dakr@redhat.com>
Subject: Re: [PATCH drm-misc-next v3] drm/sched: implement dynamic job-flow control
Date: Fri, 27 Oct 2023 11:06:44 +0200	[thread overview]
Message-ID: <190e3ab7-6440-4d41-a79f-5dd4b7d3ca52@amd.com> (raw)
In-Reply-To: <20231027102237.0cdb85af@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 4208 bytes --]

Am 27.10.23 um 10:22 schrieb Boris Brezillon:
> On Fri, 27 Oct 2023 09:44:13 +0200
> Christian König<christian.koenig@amd.com>  wrote:
>
>> Am 27.10.23 um 09:39 schrieb Boris Brezillon:
>>> On Fri, 27 Oct 2023 09:35:01 +0200
>>> Christian König<christian.koenig@amd.com>   wrote:
>>>   
>>>> Am 27.10.23 um 09:32 schrieb Boris Brezillon:
>>>>> On Fri, 27 Oct 2023 09:22:12 +0200
>>>>> Christian König<christian.koenig@amd.com>   wrote:
>>>>>      
>>>>>>> +
>>>>>>> +	/**
>>>>>>> +	 * @update_job_credits: Called once the scheduler is considering this
>>>>>>> +	 * job for execution.
>>>>>>> +	 *
>>>>>>> +	 * Drivers may use this to update the job's submission credits, which is
>>>>>>> +	 * useful to e.g. deduct the number of native fences which have been
>>>>>>> +	 * signaled meanwhile.
>>>>>>> +	 *
>>>>>>> +	 * The callback must either return the new number of submission credits
>>>>>>> +	 * for the given job, or zero if no update is required.
>>>>>>> +	 *
>>>>>>> +	 * This callback is optional.
>>>>>>> +	 */
>>>>>>> +	u32 (*update_job_credits)(struct drm_sched_job *sched_job);
>>>>>> Why do we need an extra callback for this?
>>>>>>
>>>>>> Just document that prepare_job() is allowed to reduce the number of
>>>>>> credits the job might need.
>>>>> ->prepare_job() is called only once if the returned fence is NULL, but
>>>>> we need this credit-update to happen every time a job is considered for
>>>>> execution by the scheduler.
>>>> But the job is only considered for execution once. How do you see that
>>>> this is called multiple times?
>>> Nope, it's not. If drm_sched_can_queue() returns false, the scheduler
>>> will go look for another entity that has a job ready for execution, and
>>> get back to this entity later, and test drm_sched_can_queue() again.
>>> Basically, any time drm_sched_can_queue() is called, the job credits
>>> update should happen, so we have an accurate view of how many credits
>>> this job needs.
>> Well, that is the handling which I already rejected because it creates
>> unfairness between processes. When you consider the credits needed
>> *before* scheduling jobs with a lower credit count are always preferred
>> over jobs with a higher credit count.
> My bad, it doesn't pick another entity when an entity with a
> ready job that doesn't fit the queue is found, it just bails out from
> drm_sched_rq_select_entity_rr() and returns NULL (AKA: no ready entity
> found). But we still want to update the job credits before checking if
> the job fits or not (next time this entity is tested).

Why? I only see a few possibility here:

1. You need to wait for submissions to the same scheduler to finish 
before the one you want to push to the ring.
     This case can be avoided by trying to cast the dependency fences to 
drm_sched_fences and looking if they are already scheduled.

2. You need to wait for submissions to a different scheduler instance 
and in this case you should probably return that as dependency instead.

So to me it looks like when prepare_job() is called because it is 
selected as next job for submission you should already know how many 
credits it needs.

>> What you can do is to look at the credits of a job *after* it was picked
>> up for scheduling so that you can scheduler more jobs.
> Sure, but then you might further delay your job if something made it
> smaller (ie. native fences got signaled) between ->prepare_job() and
> drm_sched_can_queue(). And any new drm_sched_can_queue() test would
> just see the old credits value.
>
> Out of curiosity, what are you worried about with this optional
> ->update_job_credits() call in the drm_sched_can_queue() path? Is the
> if (sched->update_job_credits) overhead considered too high for drivers
> that don't need it?

Since the dma_fences are also used for resource management the scheduler 
is vital for correct system operation.

We had massively problems because people tried to over-optimize the 
dma_fence handling which lead to very hard to narrow down memory 
corruptions.

So for every change you come up here you need to have a very very good 
justification. And just saving a bit size of your ring buffer is 
certainly not one of them.

Regards,
Christian.

[-- Attachment #2: Type: text/html, Size: 5925 bytes --]

  reply	other threads:[~2023-10-27  9:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 16:13 [PATCH drm-misc-next v3] drm/sched: implement dynamic job-flow control Danilo Krummrich
2023-10-26 21:13 ` Luben Tuikov
2023-10-27  1:03   ` Luben Tuikov
2023-10-27  7:17 ` Boris Brezillon
     [not found]   ` <794f9b45-db0d-4261-aefe-7da2ad0ed3b7@redhat.com>
2023-10-27 16:26     ` Boris Brezillon
2023-10-28  3:34       ` Luben Tuikov
2023-10-27  7:22 ` Christian König
2023-10-27  7:32   ` Boris Brezillon
2023-10-27  7:35     ` Christian König
2023-10-27  7:39       ` Boris Brezillon
2023-10-27  7:44         ` Christian König
2023-10-27  8:22           ` Boris Brezillon
2023-10-27  9:06             ` Christian König [this message]
2023-10-27 10:17               ` Boris Brezillon
2023-10-30  7:38                 ` Christian König
2023-10-30 17:56                   ` Danilo Krummrich
2023-10-31 13:20                     ` Christian König
2023-10-31 15:01                       ` Danilo Krummrich
     [not found]                         ` <8d4a0870-f7d0-41ee-aa25-6488b6ea037a@amd.com>
     [not found]                           ` <ZUPkfKzgKqhqQhMI@pollux>
     [not found]                             ` <c91cf097-2ed3-4669-b9ae-b16b5f875b02@amd.com>
2023-11-06 16:46                               ` Danilo Krummrich
2023-11-07  9:13                                 ` Christian König
2023-11-07 13:03                                   ` Danilo Krummrich
2023-10-27  8:25 ` Boris Brezillon
     [not found]   ` <8e117f9f-a01c-4242-8781-b2ed4969513b@redhat.com>
2023-10-27 16:31     ` Boris Brezillon
2023-10-28  3:37       ` Luben Tuikov
     [not found]   ` <a9215c37-61cd-4fbc-9f80-217daacd96bd@gmail.com>
     [not found]     ` <20231027184143.4427edb8@collabora.com>
2023-10-28  3:51       ` Luben Tuikov

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=190e3ab7-6440-4d41-a79f-5dd4b7d3ca52@amd.com \
    --to=christian.koenig@amd.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith@gfxstrand.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luben.tuikov@amd.com \
    --cc=matthew.brost@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox