From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796131172; b=P1BMAuzd0pV3/+1sdBf/PX4VghoUA5yA97xNDYyqqhDnM30EIUgiX2hF/D3KmJf45Uj0 /bycW9k1eo/rJhgv01MmaPjoeaLwRuBSX/FjmXpPOgOIignBZJgbbh0ekTVLnY5yLZ69U AyfVywcVSc+8PMIHtBwsOOdWFo+VY49RnlPmjyXKOzCeH8wF/WQPUu5IZplcSZIXk18Wg EwnbXP0VttQfcpGgHUtIZWrcD8Vu50sx961gfs6aRteCCAcmeoZkGCciNMply+XIqqIJ2 oerP1Z2gRatCmv0YCFk0JjDka1Kfn+1OtvnWEfRHtYhJChIuUKryYGiJIPLTXqc/IiQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131172; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=VSXp7z46IDBUSev5PoprdU2/46Btk43Zlzr+nCXN/s0=; b=IgY+pV48BNwqFX1pI9PaBKvd3sMT1hdesyDGJ6A3qAMBpFQAvl0qJtnTdCIWY8mMxTC4 eCD9mWiO2rOf8aUCg6CroJjwgcUJVZgNYzS/u9arjjEJY2xDjKg4u8PmUycnq3TEkFecw 4wEIV9vBMRPVpgM65GD8HfA8zv50JvB2OTH1nQF//wkBzkhzpu+XThobrkMe2z8ARMszk LWGQc0HlfowJ5q8y/tziOGGVQP4sOt0ZAmyCo3VdWZs+3Ni4KjK/ym8nenArX0AZQVKzS ttxUhnieRb06erqjAX+HlOZ6X5h0Up/wrCfDvs+KnZQYAV7IIcCXzNpp6evdyZCw4Bw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=OfQ8stHZ; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 Received: from sender6-pp-f112.zoho.com (sender6-pp-f112.zoho.com [165.173.180.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 392FB606A320; Tue, 1 Dec 2026 13:19:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 392FB606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=OfQ8stHZ ARC-Seal: i=1; a=rsa-sha256; t=1796131146; cv=none; d=zohomail.com; s=zohoarc; b=WXRdZwqtr0tIDaeD1ZRLcnIDmB5rM0rfkGO6TYFeUjIFLokMhf9xq4cBKAlAAZSK75pncoaG3/zukHBavB0gJNRAQXSGQNA87RJUTuFoOYgjzRTL7xms5zZ3cK/z6MbD5hUNfPphszZDJH7fabgKkiFEt28bmGGMDN1g+FRGJog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796131146; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=VSXp7z46IDBUSev5PoprdU2/46Btk43Zlzr+nCXN/s0=; b=mZeAKScYGDH0hgFV2bEPnzkKjACy/nsklpJj3UVrcFSxwaQ9928UT1UJG7UmdHR6gcgtO8oNXrqQo0dUgV52lhWdwEjeY/lErTvL3NwSKXsfbMsBojJZHpCySoSrOk8CkO3tX1DkNALe6m5hHBSvbdomFp8ErAow7B6zHqUKRU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=OfQ8stHZw7k4tgTDIOmDqu0eNDpls98UrQk21Enbl9Gq4bZkyKlK6ogifJsE1p/vs5FW4EPFSpDKaTK3XREQCCJcMzm+5R1MNAvADR7OnmXxnfedOvxj29jRa8MS89bk0svIsv1I5TdwK8sZGfUSOCXFkelxQY2YLczO4qT+Aic=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=VSXp7z46IDBUSev5PoprdU2/46Btk43Zlzr+nCXN/s0=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796131145030614.9325100699994; Tue, 1 Dec 2026 05:19:05 -0800 (PST) From: Nicolas Frattaroli To: Boris Brezillon , Matthew Brost , Danilo Krummrich , Philipp Stanner , Christian =?UTF-8?B?S8O2bmln?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Luben Tuikov , phasta@kernel.org 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 14:18:59 +0100 Message-ID: In-Reply-To: <132b66f04e0ed601e45f721f777834b15bf05ed3.camel@mailbox.org> References: <20261128-drm-sched-fini-race-v1-1-9803ee8aa8b4@collabora.com> <132b66f04e0ed601e45f721f777834b15bf05ed3.camel@mailbox.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" On Tuesday, 1 December 2026 08:56:35 Central European Standard Time Philipp Stanner wrote: > 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? Will do. My current solution also has a deadlock according to both sashiko and casual reading of the code, but funnily enough I could not yet trigger a lockdep splat by running both code paths. Basically work_tdr can and will start/stop the drm_sched as well, so synchronously disabling it while holding the pause_lock in drm_sched_fini is a bad idea. In practice, lockdep has somehow not complained, despite me confirming with ftrace that both the timedout function ran and the drm_sched_fini function ran. I guess because in none of those executions, the timedout thread synchronised with drm_sched_fini? Who knows. Kind regards, Nicolas Frattaroli > > > Thx > P. >