mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: phasta@kernel.org, "Min Ma" <mamin506@gmail.com>,
	"Lizhi Hou" <lizhi.hou@amd.com>,
	"Oded Gabbay" <ogabbay@kernel.org>,
	"Rob Herring (Arm)" <robh@kernel.org>,
	"Tomeu Vizoso" <tomeu@tomeuvizoso.net>,
	"Karol Wachowski" <karol.wachowski@linux.intel.com>,
	"Andrzej Kacprowski" <andrzej.kacprowski@linux.intel.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Felix Kuehling" <Felix.Kuehling@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Russell King" <linux+etnaviv@armlinux.org.uk>,
	"Christian Gmeiner" <christian.gmeiner@gmail.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Tvrtko Ursulin" <tursulin@ursulin.net>,
	"Alessio Belle" <alessio.belle@imgtec.com>,
	"Luigi Santivetti" <luigi.santivetti@imgtec.com>,
	"Qiang Yu" <yuq825@gmail.com>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	"Dmitry Baryshkov" <lumag@kernel.org>,
	"Abhinav Kumar" <abhinav.kumar@linux.dev>,
	"Jessica Zhang" <jesszhan0024@gmail.com>,
	"Sean Paul" <sean@poorly.run>,
	"Marijn Suijten" <marijn.suijten@somainline.org>,
	"Lyude Paul" <lyude@redhat.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	"Steven Price" <steven.price@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Natalie Vock" <nat@pixelcluster.dev>,
	"Arun Pravin" <arunpravin.paneerselvam@amd.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Melissa Wen" <mwen@igalia.com>,
	"Maíra Canal" <mcanal@igalia.com>,
	"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
	"Raspberry Pi Kernel Maintenance" <kernel-list@raspberrypi.com>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Chia-I Wu" <olvaffe@gmail.com>,
	"Zack Rusin" <zack.rusin@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Thierry Reding" <thierry.reding@kernel.org>,
	"Mikko Perttunen" <mperttunen@nvidia.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Sunil Khatri" <sunil.khatri@amd.com>,
	"Kees Cook" <kees@kernel.org>,
	"Jesse Zhang" <jesse.zhang@amd.com>,
	"Timur Kristóf" <timur.kristof@gmail.com>,
	"Srinivasan Shanmugam" <srinivasan.shanmugam@amd.com>,
	"Kexin Sun" <kexinsun@smail.nju.edu.cn>,
	"Prike Liang" <Prike.Liang@amd.com>,
	"David Rosca" <david.rosca@amd.com>,
	"Krzysztof Karas" <krzysztof.karas@intel.com>,
	"Marco Crivellari" <marco.crivellari@suse.com>,
	"Shixiong Ou" <oushixiong@kylinos.cn>,
	"Jouni Högander" <jouni.hogander@intel.com>,
	"Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>,
	"Pierre-Eric Pelloux-Prayer" <pierre-eric.pelloux-prayer@amd.com>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Neill Kapron" <nkapron@google.com>,
	"Michael Bommarito" <michael.bommarito@gmail.com>,
	"Sam Day" <me@samcday.com>,
	"Gabriel Prostitis" <prostitisgabriel@gmail.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 linux-media@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	 etnaviv@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	 imagination@lists.freedesktop.org, lima@lists.freedesktop.org,
	 linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	 nouveau@lists.freedesktop.org, virtualization@lists.linux.dev,
	 spice-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org,  linux-tegra@vger.kernel.org,
	linux-iio@vger.kernel.org,  linux-usb@vger.kernel.org
Subject: Re: [RFC PATCH 0/6] dma-buf: Phase out is_signaled() race
Date: Thu, 29 Oct 2026 12:23:45 +0100	[thread overview]
Message-ID: <d0610126883f23bec3472f41e528aae786f27c8c.camel@pengutronix.de> (raw)
In-Reply-To: <3565783722927fa48a30f48b063ef99bcd703eab.camel@mailbox.org>

Am Donnerstag, dem 29.10.2026 um 11:28 +0100 schrieb Philipp Stanner:
> On Thu, 2026-10-29 at 11:23 +0100, Lucas Stach wrote:
> > Hi Philipp, hi Christian,
> 
> Jo Lucas
> 
> > 
> > Am Donnerstag, dem 29.10.2026 um 10:55 +0100 schrieb Philipp Stanner:
> 
> […]
> 
> > I think we would all be interested in the actual use-case that's
> > sensitive to this kind of latency.
> 
> Me too.
> 
> Let me use this opportunity to stress that in the future, in DRM,
> whenever we have [to accept] a racy "optimization", both commit
> messages and code comments must document why it exists and who
> requested it with what proof.
> 
I don't fully agree that this is a racy optimization. To me it seems
the most critical issue here is that "fence is signaled" is under
specified.

Does it purely mean that the actual hardware operation that the fence
is guarding is done? In that case the current implementation is fine,
as the bit is only set after the HW told us that it is done. This is
the interpretation I would assume was the original intent behind the
current implementation.

Does it mean that the hardware is done and all registered callbacks
have been run, even if the actual work is done in a (indefinitely)
deferred worker? You mentioning explosions caused by the pure signal
state check outside the lock would imply that some consumers of the
fence took the signaled state to mean this interpretation.

> Would save us lots of time when those things are discussed >5 years
> later.
> 
> > 
> > However, I wonder if this is even an issue anymore with the lock
> > inlined into the fence structure.
> 
> Almost no one uses inline-lock so far. So unfortunately, we might
> regress old drivers, maybe.
> 
> But sounds as if you're in favor of phasing the locklessness out :)
> 
I'm in favor of ripping out hard to reason optimizations if they turn
out to not provide any optimization after all. However, before going in
either direction we need to clarify the fence signal state interface. 

Either we keep the (in my interpretation) original intent of the signal
state only telling about HW progress state and thus declare some
current uses as wrong usage of the interface, which need to be fixed.
Or we need to include the SW callbacks too, but then your current lock
approach only guards against code directly executed in the callback
functions. If the implementation of the callback defers anything to a
worker this may still be racy.
And that's also my criticism to this patchset now that I thought a bit
more about this: by simply putting things under the lock you serialized
more of the SW state without actually better defining the guarantees
that this changed fence interface provides or doesn't provide to the
consumers.

Regards,
Lucas

  reply	other threads:[~2026-10-29 11:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  9:55 Philipp Stanner
2026-10-29  9:55 ` [RFC PATCH 1/6] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
2026-10-29 13:38   ` Christian König
2026-10-29  9:55 ` [RFC PATCH 2/6] dma-buf: dma-fence: Add flag for using 64-bit seqnos Philipp Stanner
2026-10-29  9:55 ` [RFC PATCH 3/6] dma-buf: Port users of dma_fence_init64() Philipp Stanner
2026-10-29  9:55 ` [RFC PATCH 4/6] dma-buf: dma-fence: remove dma_fence_init64() Philipp Stanner
2026-10-29  9:55 ` [RFC PATCH 5/6] dma-buf: dma-fence: Close race in dma_fence_is_signaled() by default Philipp Stanner
2026-10-29 16:00   ` Matthew Brost
2026-10-29  9:55 ` [RFC PATCH 6/6] drm/nouveau: Remove hacky fence check Philipp Stanner
2026-10-29 10:23 ` [RFC PATCH 0/6] dma-buf: Phase out is_signaled() race Lucas Stach
2026-10-29 10:28   ` Philipp Stanner
2026-10-29 11:23     ` Lucas Stach [this message]
2026-10-29 13:43     ` Christian König

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=d0610126883f23bec3472f41e528aae786f27c8c.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=Felix.Kuehling@amd.com \
    --cc=Prike.Liang@amd.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=alessio.belle@imgtec.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrzej.kacprowski@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=boris.brezillon@collabora.com \
    --cc=cascardo@igalia.com \
    --cc=christian.gmeiner@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dakr@kernel.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=david.rosca@amd.com \
    --cc=dlechner@baylibre.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gurchetansingh@chromium.org \
    --cc=imagination@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jesse.zhang@amd.com \
    --cc=jesszhan0024@gmail.com \
    --cc=jic23@kernel.org \
    --cc=joelagnelf@nvidia.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=jouni.hogander@intel.com \
    --cc=karol.wachowski@linux.intel.com \
    --cc=kees@kernel.org \
    --cc=kernel-list@raspberrypi.com \
    --cc=kexinsun@smail.nju.edu.cn \
    --cc=kraxel@redhat.com \
    --cc=krzysztof.karas@intel.com \
    --cc=lima@lists.freedesktop.org \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lizhi.hou@amd.com \
    --cc=luigi.santivetti@imgtec.com \
    --cc=lumag@kernel.org \
    --cc=lyude@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mamin506@gmail.com \
    --cc=marco.crivellari@suse.com \
    --cc=marijn.suijten@somainline.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mcanal@igalia.com \
    --cc=me@samcday.com \
    --cc=michael.bommarito@gmail.com \
    --cc=mperttunen@nvidia.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=nat@pixelcluster.dev \
    --cc=nkapron@google.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=nuno.sa@analog.com \
    --cc=ogabbay@kernel.org \
    --cc=olvaffe@gmail.com \
    --cc=oushixiong@kylinos.cn \
    --cc=phasta@kernel.org \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=prostitisgabriel@gmail.com \
    --cc=robh@kernel.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=spice-devel@lists.freedesktop.org \
    --cc=srinivasan.shanmugam@amd.com \
    --cc=steven.price@arm.com \
    --cc=sumit.semwal@linaro.org \
    --cc=sunil.khatri@amd.com \
    --cc=thierry.reding@kernel.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=timur.kristof@gmail.com \
    --cc=tomeu@tomeuvizoso.net \
    --cc=tursulin@ursulin.net \
    --cc=tzimmermann@suse.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=virtualization@lists.linux.dev \
    --cc=yuq825@gmail.com \
    --cc=zack.rusin@broadcom.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®