From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: "Ke Sun" <sunke@kylinos.cn>, "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Lyude Paul" <lyude@redhat.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Sami Tolvanen" <samitolvanen@google.com>,
rust-for-linux@vger.kernel.org, linux-mm@kvack.org,
dri-devel@lists.freedesktop.org, driver-core@lists.linux.dev,
"Alvin Sun" <alvin.sun@linux.dev>
Subject: Re: [PATCH v3 04/11] drm/tyr: add per-file VM pool
Date: Tue, 13 Oct 2026 17:11:22 -0700 [thread overview]
Message-ID: <as7IqjINtIURG4yi@um790> (raw)
In-Reply-To: <B20D93F5-4950-4E9C-8E3B-E2DC476DA539@collabora.com>
On Sat, Oct 10, 2026 at 04:33:32PM -0300, Daniel Almeida wrote:
> Hi Deb,
>
> I find it unidiomatic to have containers destroy an item if addition fails. A
> more common pattern is to return the item in an error. Something like:
>
> pub(crate) struct AddError<'drm> {
> pub(crate) error: Error,
> pub(crate) vm: Arc<Vm<'drm>>,
> }
>
> This would not convert automatically to Error, so callers could not simply "?"
> it, they have to handle it:
>
> pool.add(vm).map_err(|e| {
> e.vm.kill();
> e.error
> })?;
Interesting, I see what you mean because it would give the caller control
over the vm and managing its tear down. And it would be nice to separate
the creation of the vm from inserting it into the pool. I implemented this
myself and that's fine if you want to go with adding a custom VmAddError
or something like that.
But, would you also consider going the other way and actually creating
the vm inside VmPool::add()?
One advantage of this approach is that we don't have to create the vm at
all if there are no ids available so we can just return ENOSPC.
And, since we have to kill a prev_vm if store unexpectedly returns a vm,
then this would centralize vm creation, registration, and failure cleanup
all in a single place. It would also be consistent with planned revisions
to VmPool::remove() which is going to take responsibility for tearing
down the vm.
>
> Don't worry, I plan to remove the need to manually call kill() soon, so this
> subject will become outdated in the near future.
>
> Paths where the Vm is already in the pool can call kill() though, this includes
> remove().
>
> -- Daniel
next prev parent reply other threads:[~2026-10-14 0:11 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 2:15 [PATCH v3 00/11] drm/tyr: add VM and BO ioctl support Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-09-29 2:15 ` [PATCH v3 01/11] rust: sizes: add SZ_4G constant Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-09-29 2:15 ` [PATCH v3 02/11] rust: mm: add `task_size` helper Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-09-29 2:15 ` [PATCH v3 03/11] rust: sync: arc: relax `ForeignOwnable` for `Arc<T>` Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-09-29 2:15 ` [PATCH v3 04/11] drm/tyr: add per-file VM pool Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-10-09 14:22 ` Daniel Almeida
2026-10-10 17:15 ` Deborah Brouwer
2026-10-10 19:33 ` Daniel Almeida
2026-10-14 0:11 ` Deborah Brouwer [this message]
2026-09-29 2:15 ` [PATCH v3 05/11] drm/tyr: add user and MCU VM specifications Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-10-09 14:26 ` Daniel Almeida
2026-10-09 14:27 ` Daniel Almeida
2026-09-29 2:15 ` [PATCH v3 06/11] drm/tyr: add BO creation and lookup helpers Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-10-09 14:28 ` Daniel Almeida
2026-09-29 2:15 ` [PATCH v3 07/11] drm/tyr: add VM-related ioctls Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-10-09 14:36 ` Daniel Almeida
2026-09-29 2:15 ` [PATCH v3 08/11] drm/tyr: add BO-related ioctls Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-10-09 14:52 ` Daniel Almeida
2026-09-29 2:15 ` [PATCH v3 09/11] rust: device: expose dma_coherent() Ke Sun
2026-09-29 2:15 ` Ke Sun via B4 Relay
2026-09-29 18:40 ` Danilo Krummrich
2026-09-29 2:16 ` [PATCH v3 10/11] drm/tyr: gem: flush write-combine BOs from probe-time coherence Ke Sun
2026-09-29 2:16 ` Ke Sun via B4 Relay
2026-09-29 2:16 ` [PATCH v3 11/11] drm/tyr: gem: map cached BOs for DRM_PANTHOR_BO_WB_MMAP Ke Sun
2026-09-29 2:16 ` Ke Sun via B4 Relay
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=as7IqjINtIURG4yi@um790 \
--to=deborah.brouwer@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=alvin.sun@linux.dev \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=simona@ffwll.ch \
--cc=sunke@kylinos.cn \
--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.