From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Ray Strode <rstrode@redhat.com>, Ray Strode <halfline@gmail.com>,
daniel.vetter@ffwll.ch, Xinhui.Pan@amd.com,
dri-devel@lists.freedesktop.org, mdaenzer@redhat.com,
alexander.deucher@amd.com, airlied@redhat.com,
christian.koenig@amd.com
Subject: Re: [PATCH] drm/atomic: Perform blocking commits on workqueue
Date: Thu, 5 Oct 2023 13:16:27 +0300 [thread overview]
Message-ID: <ZR6M-6q_yRc-j_fG@intel.com> (raw)
In-Reply-To: <ZR6IlVR-A5KtIHEU@phenom.ffwll.local>
On Thu, Oct 05, 2023 at 11:57:41AM +0200, Daniel Vetter wrote:
> On Tue, Sep 26, 2023 at 01:05:49PM -0400, Ray Strode wrote:
> > From: Ray Strode <rstrode@redhat.com>
> >
> > A drm atomic commit can be quite slow on some hardware. It can lead
> > to a lengthy queue of commands that need to get processed and waited
> > on before control can go back to user space.
> >
> > If user space is a real-time thread, that delay can have severe
> > consequences, leading to the process getting killed for exceeding
> > rlimits.
> >
> > This commit addresses the problem by always running the slow part of
> > a commit on a workqueue, separated from the task initiating the
> > commit.
> >
> > This change makes the nonblocking and blocking paths work in the same way,
> > and as a result allows the task to sleep and not use up its
> > RLIMIT_RTTIME allocation.
> >
> > Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2861
> > Signed-off-by: Ray Strode <rstrode@redhat.com>
>
> So imo the trouble with this is that we suddenly start to make
> realtime/cpu usage guarantees in the atomic ioctl. That's a _huge_ uapi
> change, because even limited to the case of !ALLOW_MODESET we do best
> effort guarantees at best. And some drivers (again amd's dc) spend a ton
> of cpu time recomputing state even for pure plane changes without any crtc
> changes like dpms on/off (at least I remember some bug reports about
> that). And that state recomputation has to happen synchronously, because
> it always influences the ioctl errno return value.
>
> My take is that you're papering over a performance problem here of the
> "the driver is too slow/wastes too much cpu time". We should fix the
> driver, if that's possible.
>
> Another option would be if userspace drops realtime priorities for these
> known-slow operations. And right now _all_ kms operations are potentially
> cpu and real-time wasters, the entire uapi is best effort.
>
> We can also try to change the atomic uapi to give some hard real-time
> guarantees so that running compositors as SCHED_RT is possible, but that
> - means a very serious stream of bugs to fix all over
> - therefore needs some very wide buy-in from drivers that they're willing
> to make this guarantee
> - probably needs some really carefully carved out limitations, because
> there's imo flat-out no way we'll make all atomic ioctl hard time limit
> bound
>
> Also, as König has pointed out, you can roll this duct-tape out in
> userspace by making the commit non-blocking and immediately waiting for
> the fences.
>
> One thing I didn't see mention is that there's a very subtle uapi
> difference between non-blocking and blocking:
> - non-blocking is not allowed to get ahead of the previous commit, and
> will return EBUSY in that case. See the comment in
> drm_atomic_helper_commit()
> - blocking otoh will just block until any previous pending commit has
> finished
>
> Not taking that into account in your patch here breaks uapi because
> userspace will suddenly get EBUSY when they don't expect that.
The -EBUSY logic already checks whether the current commit is
non-blocking vs. blocking commit, so I don't see how there would
be any change in behaviour from simply stuffing the commit_tail
onto a workqueue, especially as the locks will be still held across
the flush.
In my earlier series [1] where I move the flush to happen after dropping
the locks there is a far more subtle issue because currently even
non-blocking commits can actually block due to the mutex. Changing
that might break something, so I preserved that behaviour explicitly.
Full explanation in the first patch there.
[1] https://patchwork.freedesktop.org/series/108668/
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2023-10-05 10:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 17:05 [PATCH] drm/atomic: Perform blocking commits on workqueue Ray Strode
2023-09-27 8:04 ` Christian König
2023-09-27 20:25 ` Ray Strode
2023-09-28 6:56 ` Christian König
2023-09-28 9:43 ` Michel Dänzer
2023-09-28 12:59 ` Ray Strode
2023-09-28 13:37 ` Michel Dänzer
2023-09-28 14:51 ` Christian König
2023-09-28 15:19 ` Michel Dänzer
2023-09-28 12:46 ` Ray Strode
2023-09-28 13:23 ` Christian König
2023-09-28 13:58 ` Michel Dänzer
2023-09-28 15:02 ` Christian König
2023-09-28 14:20 ` Ray Strode
2023-09-28 15:03 ` Ville Syrjälä
2023-09-28 19:33 ` Ray Strode
2023-10-04 17:27 ` Ville Syrjälä
2023-10-04 19:38 ` Ray Strode
2023-10-05 9:57 ` Daniel Vetter
2023-10-05 10:16 ` Ville Syrjälä [this message]
2023-10-10 11:36 ` Daniel Vetter
2023-10-05 11:51 ` Christian König
2023-10-05 21:04 ` Ray Strode
2023-10-06 7:12 ` Christian König
2023-10-06 18:48 ` Ray Strode
2023-10-08 10:37 ` Michel Dänzer
2023-10-09 6:42 ` Christian König
2023-10-09 12:19 ` Ville Syrjälä
2023-10-09 12:36 ` Christian König
2023-10-10 11:41 ` Daniel Vetter
2023-10-12 18:19 ` Ray Strode
2023-10-13 9:41 ` Daniel Vetter
2023-10-13 10:22 ` Michel Dänzer
2023-10-17 7:32 ` Daniel Vetter
2023-10-17 7:55 ` Christian König
2023-10-13 14:04 ` Ray Strode
2023-10-17 7:37 ` Daniel Vetter
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=ZR6M-6q_yRc-j_fG@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=halfline@gmail.com \
--cc=mdaenzer@redhat.com \
--cc=rstrode@redhat.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