Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Danilo Krummrich <dakr@redhat.com>,
	Matthew Brost <matthew.brost@intel.com>
Cc: robdclark@chromium.org, sarah.walker@imgtec.com,
	ketil.johnsen@arm.com, lina@asahilina.net, Liviu.Dudau@arm.com,
	dri-devel@lists.freedesktop.org, luben.tuikov@amd.com,
	donald.robson@imgtec.com, boris.brezillon@collabora.com,
	intel-xe@lists.freedesktop.org, faith.ekstrand@collabora.com
Subject: Re: [Intel-xe] [PATCH v2 1/9] drm/sched: Convert drm scheduler to use a work queue rather than kthread
Date: Tue, 22 Aug 2023 11:35:15 +0200	[thread overview]
Message-ID: <1cc74496-6c99-3ef5-3710-a092091ef2ea@amd.com> (raw)
In-Reply-To: <faecd15e-020b-6b06-acf7-1dd4c5a2b4fc@redhat.com>

Am 21.08.23 um 21:07 schrieb Danilo Krummrich:
> On 8/21/23 20:12, Christian König wrote:
>> Am 21.08.23 um 20:01 schrieb Danilo Krummrich:
>>> On 8/21/23 16:07, Christian König wrote:
>>>> Am 18.08.23 um 13:58 schrieb Danilo Krummrich:
>>>>> [SNIP]
>>>>>> I only see two possible outcomes:
>>>>>> 1. You return -EBUSY (or similar) error code indicating the the 
>>>>>> hw can't receive more commands.
>>>>>> 2. Wait on previously pushed commands to be executed.
>>>>>> (3. Your driver crash because you accidentally overwrite stuff in 
>>>>>> the ring buffer which is still executed. I just assume that's 
>>>>>> prevented).
>>>>>>
>>>>>> Resolution #1 with -EBUSY is actually something the UAPI should 
>>>>>> not do, because your UAPI then depends on the specific timing of 
>>>>>> submissions which is a really bad idea.
>>>>>>
>>>>>> Resolution #2 is usually bad because it forces the hw to run dry 
>>>>>> between submission and so degrade performance.
>>>>>
>>>>> I agree, that is a good reason for at least limiting the maximum 
>>>>> job size to half of the ring size.
>>>>>
>>>>> However, there could still be cases where two subsequent jobs are 
>>>>> submitted with just a single IB, which as is would still block 
>>>>> subsequent jobs to be pushed to the ring although there is still 
>>>>> plenty of space. Depending on the (CPU) scheduler latency, such a 
>>>>> case can let the HW run dry as well.
>>>>
>>>> Yeah, that was intentionally not done as well. The crux here is 
>>>> that the more you push to the hw the worse the scheduling 
>>>> granularity becomes. It's just that neither Xe nor Nouveau relies 
>>>> that much on the scheduling granularity at all (because of hw queues).
>>>>
>>>> But Xe doesn't seem to need that feature and I would still try to 
>>>> avoid it because the more you have pushed to the hw the harder it 
>>>> is to get going again after a reset.
>>>>
>>>>>
>>>>> Surely, we could just continue decrease the maximum job size even 
>>>>> further, but this would result in further overhead on user and 
>>>>> kernel for larger IB counts. Tracking the actual job size seems to 
>>>>> be the better solution for drivers where the job size can vary 
>>>>> over a rather huge range.
>>>>
>>>> I strongly disagree on that. A larger ring buffer is trivial to 
>>>> allocate 
>>>
>>> That sounds like a workaround to me. The problem, in the case above, 
>>> isn't that the ring buffer does not have enough space, the problem 
>>> is that we account for the maximum job size although the actual job 
>>> size is much smaller. And enabling the scheduler to track the actual 
>>> job size is trivial as well.
>>
>> That's what I agree on, so far I just didn't see the reason for doing 
>> it but at least a few reason for not doing it.
>>
>>>
>>>> and if userspace submissions are so small that the scheduler can't 
>>>> keep up submitting them then your ring buffer size is your smallest 
>>>> problem.
>>>>
>>>> In other words the submission overhead will completely kill your 
>>>> performance and you should probably consider stuffing more into a 
>>>> single submission.
>>>
>>> I fully agree and that is also the reason why I want to keep the 
>>> maximum job size as large as possible.
>>>
>>> However, afaik with Vulkan it's the applications themselves deciding 
>>> when and with how many command buffers a queue is submitted (@Faith: 
>>> please correct me if I'm wrong). Hence, why not optimize for this 
>>> case as well? It's not that it would make another case worse, right?
>>
>> As I said it does make both the scheduling granularity as well as the 
>> reset behavior worse.
>
> As you already mentioned Nouveau (and XE) don't really rely much on 
> scheduling granularity. For Nouveau, the same is true for the reset 
> behavior; if things go south the channel is killed anyway. Userspace 
> would just request a new ring in this case.
>
> Hence, I think Nouveau would profit from accounting the actual job 
> size. And at the same time, other drivers having a benefit of always 
> accounting for the maximum job size would still do so, by default.
>
> Arbitrary ratios of how much the job size contributes to the ring 
> being considered as full would also be possible.

That would indeed be rather interesting since for a bunch of drivers the 
limiting part is not the ring buffer size, but rather the utilization of 
engines.

But no idea how to properly design that. You would have multiple values 
to check instead of just one.

Christian.

>
> - Danilo
>
>>
>> In general I think we should try to push just enough work to the 
>> hardware to keep it busy and not as much as possible.
>>
>> So as long as nobody from userspace comes and says we absolutely need 
>> to optimize this use case I would rather not do it.
>>
>> Regards,
>> Christian.
>>
>>>
>>> - Danilo
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>>>
>>>>> - Danilo
>>>>
>>>
>>
>


  reply	other threads:[~2023-08-22  9:35 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  2:31 [Intel-xe] [PATCH v2 0/9] DRM scheduler changes for Xe Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 1/9] drm/sched: Convert drm scheduler to use a work queue rather than kthread Matthew Brost
2023-08-16 11:30   ` Danilo Krummrich
2023-08-16 14:05     ` Christian König
2023-08-16 12:30       ` Danilo Krummrich
2023-08-16 14:38         ` Matthew Brost
2023-08-16 15:40           ` Danilo Krummrich
2023-08-16 14:59         ` Christian König
2023-08-16 16:33           ` Danilo Krummrich
2023-08-17  5:33             ` Christian König
2023-08-17 11:13               ` Danilo Krummrich
2023-08-17 13:35                 ` Christian König
2023-08-17 12:48                   ` Danilo Krummrich
2023-08-17 16:17                     ` Christian König
2023-08-18 11:58                       ` Danilo Krummrich
2023-08-21 14:07                         ` Christian König
2023-08-21 18:01                           ` Danilo Krummrich
2023-08-21 18:12                             ` Christian König
2023-08-21 19:07                               ` Danilo Krummrich
2023-08-22  9:35                                 ` Christian König [this message]
2023-08-21 19:46                               ` Faith Ekstrand
2023-08-22  9:51                                 ` Christian König
2023-08-22 16:55                                   ` Faith Ekstrand
2023-08-24 11:50                                     ` Bas Nieuwenhuizen
2023-08-18  3:08                 ` Matthew Brost
2023-08-18  5:40                   ` Christian König
2023-08-18 12:49                     ` Matthew Brost
2023-08-18 12:06                       ` Danilo Krummrich
2023-09-12 14:28                 ` Boris Brezillon
2023-09-12 14:33                   ` Danilo Krummrich
2023-09-12 14:49                     ` Boris Brezillon
2023-09-12 15:13                       ` Boris Brezillon
2023-09-12 16:58                         ` Danilo Krummrich
2023-09-12 16:52                       ` Danilo Krummrich
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 2/9] drm/sched: Move schedule policy to scheduler / entity Matthew Brost
2023-08-11 21:43   ` Maira Canal
2023-08-12  3:20     ` Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 3/9] drm/sched: Add DRM_SCHED_POLICY_SINGLE_ENTITY scheduling policy Matthew Brost
2023-08-29 17:37   ` Danilo Krummrich
2023-09-05 11:10     ` Danilo Krummrich
2023-09-11 19:44       ` Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 4/9] drm/sched: Split free_job into own work item Matthew Brost
2023-08-17 13:39   ` Christian König
2023-08-17 17:54     ` Matthew Brost
2023-08-18  5:27       ` Christian König
2023-08-18 13:13         ` Matthew Brost
2023-08-21 13:17           ` Christian König
2023-08-23  3:27             ` Matthew Brost
2023-08-23  7:10               ` Christian König
2023-08-23 15:24                 ` Matthew Brost
2023-08-23 15:41                   ` Alex Deucher
2023-08-23 17:26                     ` Rodrigo Vivi
2023-08-23 23:12                       ` Matthew Brost
2023-08-24 11:44                         ` Christian König
2023-08-24 14:30                           ` Matthew Brost
2023-08-24 23:04   ` Danilo Krummrich
2023-08-25  2:58     ` Matthew Brost
2023-08-25  8:02       ` Christian König
2023-08-25 13:36         ` Matthew Brost
2023-08-25 13:45           ` Christian König
2023-09-12 10:13             ` Boris Brezillon
2023-09-12 10:46               ` Danilo Krummrich
2023-09-12 12:18                 ` Boris Brezillon
2023-09-12 12:56                   ` Danilo Krummrich
2023-09-12 13:52                     ` Boris Brezillon
2023-09-12 14:10                       ` Danilo Krummrich
2023-09-12 13:27             ` Boris Brezillon
2023-09-12 13:34               ` Danilo Krummrich
2023-09-12 13:53                 ` Boris Brezillon
2023-08-28 18:04   ` Danilo Krummrich
2023-08-28 18:41     ` Matthew Brost
2023-08-29  1:20       ` Danilo Krummrich
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 5/9] drm/sched: Add generic scheduler message interface Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 6/9] drm/sched: Add drm_sched_start_timeout_unlocked helper Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 7/9] drm/sched: Start run wq before TDR in drm_sched_start Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 8/9] drm/sched: Submit job before starting TDR Matthew Brost
2023-08-11  2:31 ` [Intel-xe] [PATCH v2 9/9] drm/sched: Add helper to set TDR timeout Matthew Brost
2023-08-11  2:34 ` [Intel-xe] ✗ CI.Patch_applied: failure for DRM scheduler changes for Xe (rev2) Patchwork
2023-08-24  0:08 ` [Intel-xe] [PATCH v2 0/9] DRM scheduler changes for Xe Danilo Krummrich
2023-08-24  3:23   ` Matthew Brost
2023-08-24 14:51     ` Danilo Krummrich
2023-08-25  3:01 ` [Intel-xe] ✗ CI.Patch_applied: failure for DRM scheduler changes for Xe (rev3) Patchwork
2023-09-05 11:13 ` [Intel-xe] ✗ CI.Patch_applied: failure for DRM scheduler changes for Xe (rev4) Patchwork

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=1cc74496-6c99-3ef5-3710-a092091ef2ea@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@redhat.com \
    --cc=donald.robson@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith.ekstrand@collabora.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=ketil.johnsen@arm.com \
    --cc=lina@asahilina.net \
    --cc=luben.tuikov@amd.com \
    --cc=matthew.brost@intel.com \
    --cc=robdclark@chromium.org \
    --cc=sarah.walker@imgtec.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