From: Luben Tuikov <ltuikov89@gmail.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
Danilo Krummrich <dakr@redhat.com>
Cc: matthew.brost@intel.com, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, faith@gfxstrand.net,
luben.tuikov@amd.com, christian.koenig@amd.com
Subject: Re: [PATCH drm-misc-next v3] drm/sched: implement dynamic job-flow control
Date: Fri, 27 Oct 2023 23:34:48 -0400 [thread overview]
Message-ID: <57c16f9d-44d9-4bc0-9d7d-8ff70b8135f0@gmail.com> (raw)
In-Reply-To: <20231027182626.6a8ba090@collabora.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 4762 bytes --]
Hi,
On 2023-10-27 12:26, Boris Brezillon wrote:
> On Fri, 27 Oct 2023 16:34:26 +0200
> Danilo Krummrich <dakr@redhat.com> wrote:
>
>> On 10/27/23 09:17, Boris Brezillon wrote:
>>> Hi Danilo,
>>>
>>> On Thu, 26 Oct 2023 18:13:00 +0200
>>> Danilo Krummrich <dakr@redhat.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);
>>>
>>> I'm copying my late reply to v2 here so it doesn't get lost:
>>>
>>> I keep thinking it'd be simpler to make this a void function that
>>> updates s_job->submission_credits directly. I also don't see the
>>> problem with doing a sanity check on job->submission_credits. I mean,
>>> if the driver is doing something silly, you can't do much to prevent it
>>> anyway, except warn the user that something wrong has happened. If you
>>> want to
>>>
>>> WARN_ON(job->submission_credits == 0 ||
>>> job->submission_credits > job_old_submission_credits);
>>>
>>> that's fine. But none of this sanity checking has to do with the
>>> function prototype/semantics, and I'm still not comfortable with this 0
>>> => no-change. If there's no change, we should just leave
>>> job->submission_credits unchanged (or return job->submission_credits)
>>> instead of inventing a new special case.
>>
>> If we can avoid letting drivers change fields of generic structures directly
>> without any drawbacks I think we should avoid it. Currently, drivers shouldn't
>> have the need to mess with job->credits directly. The initial value is set
>> through drm_sched_job_init() and is updated through the return value of
>> update_job_credits().
>
> Fair enough. I do agree that keeping internal fields out of driver
> hands is a good thing in general, it's just that it's already
> free-for-all in so many places in drm_sched (like the fact drivers
"Free-for-all" doesn't mean we need to follow suit. We should keep
good programming practices, as this patch strives to.
> iterate the pending list in their stop-queue handling) that I didn't
> really see it as an issue. Note that's there's always the option of
> providing drm_sched_job_{update,get}_credits() helpers, with the update
> helper making sure the new credits value is consistent (smaller or
> equal to the old one, and not zero).
>
>>
>> I'm fine getting rid of the 0 => no-change semantics though. Instead we can just
>> WARN() on 0.
>
> Yeah, I think that's preferable. It's pretty easy to return the old
> value if the driver has a way to detect when nothing changed (with a
> get helper if you don't want drivers to touch the credits field).
>
>> However, if we do that I'd also want to change it for
>> drm_sched_job_init() (where 0 currently defaults to 1) such that we accept 0, but
>> WARN() accordingly.
>
> Sure. You update all drivers anyway, so passing 1 instead of 0 is not a
> big deal, I would say.
At this point in time, we should consider 1 as normal, 0 out of spec and
WARN on it but carry on and (perhaps) reset it to 1. Drivers in the future, may
see a need (i.e. do tricks) to return 0, at which point they'll submit a patch which
does two things, 1) removes the WARN, 2) removes the reset from 0 to 1, and
explain why they need to return 0 to allow (one more) job, but we're nowhere near then yet,
so status quo for now.
I don't see how it makes sense to call drm_sched_job_init(credits:0), and I believe
the code is correct to default to 1 in that case--which defaults to the current
flow control we have, which we want.
>
>>
>> I think it's consequent to either consistently give 0 a different meaning or just
>> accept it but WARN() on it.
>
> Using default as a default value makes sense when you're passing
I suppose you meant "using zero as a default value".
> zero-initialized objects that are later extended with new fields, but
> here you update the function prototype and all the call sites, so we're
> better off considering 0 as an invalid value, IMHO.
Yes, absolutely.
You never want to give 0 a meaning, since as you pointed out, it is zero-ed
memory, and as such, can have any meaning you'd like. So yes: WARN on 0;
1 is good and normal.
Regards,
Luben
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 677 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
next prev parent reply other threads:[~2023-10-28 3:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 16:13 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>
[not found] ` <20231027182626.6a8ba090@collabora.com>
2023-10-28 3:34 ` Luben Tuikov [this message]
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
[not found] ` <98988459-25a8-4ee0-89d4-cb816cbc5bef@amd.com>
2023-10-27 8:22 ` Boris Brezillon
[not found] ` <190e3ab7-6440-4d41-a79f-5dd4b7d3ca52@amd.com>
2023-10-27 10:17 ` Boris Brezillon
2023-10-30 7:38 ` Christian König
2023-10-30 17:56 ` Danilo Krummrich
[not found] ` <e9c6af32-8d2a-4f04-9c12-1170a3aa1236@amd.com>
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>
[not found] ` <20231027183158.2dc4cce4@collabora.com>
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=57c16f9d-44d9-4bc0-9d7d-8ff70b8135f0@gmail.com \
--to=ltuikov89@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=christian.koenig@amd.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
all inboxes | Powered by JetHome®