From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.241.56.152 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796056323; b=nGXZK3kxOyasWY9tRBVQMtsBVMWuLL/hzVdCdvcyD/twCzR1LtNAqlSByBYqGLM3J5J+ aS8f2QVcz7YK2bkXAFXUlJDlD8kz2KiSxKBaPWISyqc3g5oYZJADnstx6a4oALfQ2r8BW Fv2+PpS9OnnCQs0qFHlZIWQFmlt17+Y4rqDgQDnmWlTGif9NlNvRk26z7eijsCJgPcpvp pRleEtn/i2PnVUVzuGAIHwBtq2AciZbZBhy7btwcR1QukR+c0k8n4hGBcxPLPx5RRTbek VxfGTDT+wxFa9XKq1oZUfw85soaGHEcotQOaKRKiyvG1xAzkHOsb5winkIAJRThQiMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796056323; h=DMARC-Filter:Received:DKIM-Signature:Message-ID:Subject:From: Reply-To:To:Cc:Date:In-Reply-To:References:Content-Type: Content-Transfer-Encoding:User-Agent:MIME-Version:X-MBO-RS-ID: X-MBO-RS-META; bh=i9+x9kUjaQb6ipSZkthC+fwW4zFvCbyzeWd6qtL7IOs=; b=esO2ZJJ18KgxpmkBH/ZdcXz1en6zB/yJ07O9D4RZLHx2G4NZ1iqCvbIP7F5rouQ5AnEI vR5PB5CqH7xr8XoqfeQ/vj1jpd5009FALCRllZg9GcC8kfahy4Pk/gyUeE+fAACoIfr8A 4EuW2/A7qvRNPDcWPTjuF5arB3m61O5wS5uFzzEDBhEQYqEw7nRCDuHLMdWieV6c8csYn E6TzZPnKmpa1ftNKoCmAm0D0XsXwCHh24oaiW0CozoOKsY8SixC2rRWVTDCY35uF9/pL7 WPAiOjTotlAE0b3ytfpwLYfIR5ifc9iFlSXYjCVjMM1Tm1/B/CKPleTBnx4RfGZmG5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=JHmZNQNK; arc=none smtp.remote-ip=80.241.56.152 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 A8157606A31C; Mon, 30 Nov 2026 16:32:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8157606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=JHmZNQNK Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4jdV0Z3zTjzKvms; Mon, 30 Nov 2026 17:31:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1796056318; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i9+x9kUjaQb6ipSZkthC+fwW4zFvCbyzeWd6qtL7IOs=; b=JHmZNQNKLjZnVJCPTSooMX/QLzspjkxOhNVsOOvzObzF4qsYE9+tWSgsa4kJwLYJDv34oa vUyUZUchDiwfjBIBNRlYP1tiafdjfCpRo1HH+cGRhl0ZlJD2+xfVgWNXmXK06KPP486ODo Jhd6T97WdfpseginDUJ2xIQg67KXYM/KNu+bfOoSiGyKFwvfCXWYj6/1fjly94KJMn1u9R vKfvwu28oM1m7sB5+cBaTpUvN6j+uXhiIh1gWmZNyHEyES30I963zOkjxvd7/rYQAxMrVb WRgI6ohf4it5CC9ngvdvrcMqdI8F/r7XziHSIwvyc7f3fWl4H3jy0QLzgb7WqQ== Message-ID: <649a3337c3a51bd5d8fc677e531aba4fd0a0afe9.camel@mailbox.org> Subject: Re: [PATCH] drm/sched: Sanitise wqueue_start/wqueue_stop/is_stopped interleavings From: Philipp Stanner Reply-To: phasta@kernel.org To: Boris Brezillon , Nicolas Frattaroli Cc: Matthew Brost , Danilo Krummrich , Philipp Stanner , Christian =?ISO-8859-1?Q?K=F6nig?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Luben Tuikov , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, stable@vger.kernel.org Date: Mon, 30 Nov 2026 17:31:56 +0100 In-Reply-To: <20261130102418.68ed62fd@fedora1.home> References: <20261128-drm-sched-fini-race-v1-1-9803ee8aa8b4@collabora.com> <20261130102418.68ed62fd@fedora1.home> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MBO-RS-ID: 2b94835fa579ef2ec45 X-MBO-RS-META: mfthbuy5z7g3bu8ttq1sdtuyzax7zyua On Mon, 2026-11-30 at 10:24 +0100, Boris Brezillon wrote: > Hi Nicolas, >=20 [=E2=80=A6] >=20 > This feels clunky given the newly introduced lock is taken in the > stop/start helpers. I get that drm_sched_is_stopped() is the reason you > have to enforce ordering with smp_store_release(), but mixing a lock > for write accesses and lockless mechanism for read accesses feels odd. +1 > > =C2=A0bool drm_sched_is_stopped(struct drm_gpu_scheduler *sched) > > =C2=A0{ > > - return READ_ONCE(sched->pause_submit); > > + /* > > + * Ensure drm_sched_wqueue_{stop,start}() && drm_sched_is_stopped() > > + * gives a consistent view to any observer that ensures no concurrent > > + * starting or stopping operation is ongoing. > > + */ > > + return smp_load_acquire(&sched->pause_submit); >=20 > This is all super fragile IMHO, because it relies on the fact the state > of the scheduler doesn't change between the moment this helper is called > and the moment the caller decides to do something with the result. +1 > Acquiring the newly introduced pause_lock doesn't help unless we turn > drm_sched_is_stopped() into drm_sched_is_stopped_locked() and force the > caller to check the pause_submit state and do the associated action The "caller" is the right keyword here. > My gut feeling is that we should find a way to kill > drm_sched_is_stopped() altogether and try to find a replacement for all > the current users. This existing is_stopped() mechanism seems to be yet another relic where the gpu_scheduler is used a synchronisation mechanism and a storage vessel for knowledge that lies in the driver. The driver stops the scheduler, so it knows that it has stopped it. Why does it need to check at another place with drm_sched_is_stopped()? I agree that this function shouldn't exist, and the state for which function it has called on which object should be stored in driver data. A first glance at the xe code looks as if there is synchronisation with a mutex in place there, which is likely the reason why the explosion has not been observed there. amdgpu also seems to hold a mutex, except for in amdgpu_multi_ring_reset_helper_begin(). @Christian, any info on that? P.