All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: <acourbot@nvidia.com>, <daniel.almeida@collabora.com>,
	<ojeda@kernel.org>, <boqun@kernel.org>, <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
	<a.hindborg@kernel.org>, <tmgross@umich.edu>, <tamird@kernel.org>,
	<work@onurozkan.dev>, <brauner@kernel.org>, <lyude@redhat.com>,
	<j@jananu.net>, <alvin.sun@linux.dev>,
	<deborah.brouwer@collabora.com>, <laura.nao@collabora.com>,
	<beata.michalska@arm.com>, <nova-gpu@lists.linux.dev>,
	<dri-devel@lists.freedesktop.org>,
	<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 7/7] rust: drm: make Driver::File lifetime-parameterized
Date: Sat, 07 Nov 2026 14:26:42 +0100	[thread overview]
Message-ID: <DMP0HGBVA3Q9.T8UP93DA34UK@kernel.org> (raw)
In-Reply-To: <au7eV0D_44ipe3mw@google.com>

On Sat Nov 7, 2026 at 9:16 AM CET, Alice Ryhl wrote:
> On Sat, Nov 07, 2026 at 03:03:25AM +0100, Danilo Krummrich wrote:
>> +        // Run driver destructors without `filelist_mutex`. Take each link before dropping its
>> +        // allocation to avoid recursively dropping the entire chain.
>> +        while let Some(mut data) = files {
>> +            files = data.as_mut().project().next.take();
>> +            drop(data);
>> +            drm.open_count.fetch_sub(1, Release);
>> +        }
>
> Instead of transferring all the files to another linked list, how about
> taking them off the file list one-by-one? If you release the mutex in
> between dropping each file, then we still avoid deadlocks if the file
> private data destructor takes the lock.

I did consider this, and technically it would (currently) work with
list_del_init(), but I did not like it because it would be a very subtle change
in semantics from the perspective of the C code. (I.e. for C drivers the list
entry would remain intact after this callback, whereas for Rust drivers it would
be removed.)

Actually, I did hesitate to move drop() out of the filelist_mutex protected path
at all because I don't think there's a way this could actually ever produce a
lock inversion, but the "move to a separate list" approach was pretty simple and
very few code so I thought it's worth ruling it out anyway.

(In any case, I'll soon start working on the C code to implement a common
lifecycle scheme.  Once we have that, the Rust code becomes even more straight
foward.)

  reply	other threads:[~2026-11-07 13:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  2:03 [PATCH v2 0/7] lifetime-parameterized DRM File private data Danilo Krummrich
2026-11-07  2:03 ` [PATCH v2 1/7] rust: drm: rename Ioctl device context to Userspace Danilo Krummrich
2026-11-11  9:21   ` Gary Guo
2026-11-07  2:03 ` [PATCH v2 2/7] rust: drm: gem: gate open/close callbacks with RegistrationGuard Danilo Krummrich
2026-11-11  9:21   ` Gary Guo
2026-11-07  2:03 ` [PATCH v2 3/7] rust: drm: move file_operations from gem to device Danilo Krummrich
2026-11-11  9:22   ` Gary Guo
2026-11-07  2:03 ` [PATCH v2 4/7] rust: fs: add iminor() helper Danilo Krummrich
2026-11-11  9:22   ` Gary Guo
2026-11-07  2:03 ` [PATCH v2 5/7] rust: drm: wrap fops open with RegistrationGuard Danilo Krummrich
2026-11-11  9:25   ` Gary Guo
2026-11-07  2:03 ` [PATCH v2 6/7] rust: drm: return impl PinInit from DriverFile::open() Danilo Krummrich
2026-11-11  9:52   ` Gary Guo
2026-11-11 17:29   ` Daniel Almeida
2026-11-07  2:03 ` [PATCH v2 7/7] rust: drm: make Driver::File lifetime-parameterized Danilo Krummrich
2026-11-07  2:34   ` sashiko-bot
2026-11-07  8:16   ` Alice Ryhl
2026-11-07 13:26     ` Danilo Krummrich [this message]
2026-11-10 20:43       ` Alice Ryhl
2026-11-11 11:08   ` Gary Guo
2026-11-11 17:30   ` Daniel Almeida

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=DMP0HGBVA3Q9.T8UP93DA34UK@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=alvin.sun@linux.dev \
    --cc=beata.michalska@arm.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=brauner@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=deborah.brouwer@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=j@jananu.net \
    --cc=laura.nao@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.