From: Philipp Stanner <phasta@mailbox.org>
To: "Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Philipp Stanner" <phasta@kernel.org>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Luben Tuikov" <luben.tuikov@amd.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel@collabora.com, stable@vger.kernel.org
Subject: Re: [PATCH] drm/sched: Sanitise wqueue_start/wqueue_stop/is_stopped interleavings
Date: Tue, 01 Dec 2026 08:56:35 +0100 [thread overview]
Message-ID: <132b66f04e0ed601e45f721f777834b15bf05ed3.camel@mailbox.org> (raw)
In-Reply-To: <20261128-drm-sched-fini-race-v1-1-9803ee8aa8b4@collabora.com>
On Sat, 2026-11-28 at 09:27 +0100, Nicolas Frattaroli wrote:
> drm_sched_wqueue_stop() will WRITE_ONCE 1 to the sched's pause_submit
> member. This member is checked (with READ_ONCE) in every
> drm_sched_run_job_queue() and drm_sched_run_free_queue() invocation,
> which is how the two work items drm_sched_wqueue_stop() cancels would
> usually get re-armed.
>
> However, this is of little consequence on SMP systems, where the effect
> of WRITE_ONCE is not guaranteed to be ordered with READ_ONCE calls on
> other CPUs. As a consequence, during drm_sched_fini(), a work item may
> become re-armed after its call to drm_sched_wqueue_stop(), and run into
> a sched->sched_rq that is now NULL, dereferencing a NULL pointer.
I just realize that we have recently solved basically the same issue
for drm::JobQueue.
https://lore.kernel.org/rust-for-linux/20261124122951.878199-11-phasta@kernel.org/
We need to park and unpark the queue. We do that for scheduling-
reasons, but the addressed issue is basically the same since we also
use it to halt the run_worker in our JobQueue deconstructor.
The mechanism is based on an atomic bool + srcu to wait for everyone to
have seen the flag. Only then do we tear down. The flag is checked in
the worker, so no matter who might kick the worker when for what
reason, it will never access freed resources.
Maybe you can draw inspiration from that and see whether a mechanism
like that could address the observed problem in drm_sched?
Thx
P.
next prev parent reply other threads:[~2026-12-01 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 8:27 Nicolas Frattaroli
2026-11-30 9:24 ` Boris Brezillon
2026-11-30 16:31 ` Philipp Stanner
2026-12-01 7:56 ` Philipp Stanner [this message]
2026-12-01 13:18 ` Nicolas Frattaroli
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=132b66f04e0ed601e45f721f777834b15bf05ed3.camel@mailbox.org \
--to=phasta@mailbox.org \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luben.tuikov@amd.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=nicolas.frattaroli@collabora.com \
--cc=phasta@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
/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®