From: "Gary Guo" <gary@garyguo.net>
To: "Danilo Krummrich" <dakr@kernel.org>, <acourbot@nvidia.com>,
<aliceryhl@google.com>, <airlied@gmail.com>, <simona@ffwll.ch>,
<lossin@kernel.org>, <gary@garyguo.net>, <ecourtney@nvidia.com>,
<jhubbard@nvidia.com>, <matthew.auld@intel.com>,
<arunpravin.paneerselvam@amd.com>, <joelagnelf@nvidia.com>
Cc: <nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rust: gpu: buddy: tie allocations to the allocator lifetime
Date: Fri, 27 Nov 2026 00:09:20 +0000 [thread overview]
Message-ID: <DN5K1U7A1D4F.SDTIDLS3S54J@garyguo.net> (raw)
In-Reply-To: <20261126221108.3768637-1-dakr@kernel.org>
On Thu Nov 26, 2026 at 10:11 PM GMT, Danilo Krummrich wrote:
> Let the allocator's lifetime constrain the lifetime of its allocations,
> rather than having allocations keep the allocator alive through
> reference counting.
>
> This also removes an unnecessary allocation and allows GpuBuddy to be
> embedded directly in driver private data.
>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> Depends on [1].
>
> [1] https://lore.kernel.org/nova-gpu/20261126213652.3716162-1-dakr@kernel.org/
> ---
> drivers/gpu/nova-core/driver.rs | 2 +-
> drivers/gpu/nova-core/gpu.rs | 51 +++++----
> drivers/gpu/nova-core/mm.rs | 9 +-
> drivers/gpu/nova-core/mm/bar_user.rs | 20 ++--
> drivers/gpu/nova-core/mm/pagetable/map.rs | 43 ++++----
> drivers/gpu/nova-core/mm/vmm.rs | 12 +-
> rust/kernel/gpu/buddy.rs | 128 ++++++++++++----------
> 7 files changed, 147 insertions(+), 118 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
> index d6bc972d47c7..f8f5d74d2742 100644
> --- a/drivers/gpu/nova-core/driver.rs
> +++ b/drivers/gpu/nova-core/driver.rs
> @@ -133,7 +133,7 @@ fn probe<'bound>(
>
> gpu <- Gpu::new(pdev, bar, bar1).pin_chain(|_gpu| {
> #[cfg(CONFIG_NOVA_CORE_SELFTESTS)]
> - _gpu.run_selftests(pdev);
> + _gpu.as_ref().run_selftests(pdev);
> Ok(())
> }),
>
> diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
> index 2f0399100885..65290cedde11 100644
> --- a/drivers/gpu/nova-core/gpu.rs
> +++ b/drivers/gpu/nova-core/gpu.rs
> @@ -1,5 +1,10 @@
> // SPDX-License-Identifier: GPL-2.0
>
> +#![expect(
> + clippy::multiple_bound_locations,
> + reason = "pin_data generates additional outlives bounds for the borrowed MM field"
> +)]
Please use `allow` so it won't cause a semantic conflict in case I fix it this cycle.
I'll take a look of the rest later.
Best,
Gary
> +
> use core::ops::Range;
>
> use kernel::{
> @@ -383,7 +388,11 @@ unsafe fn new(
>
> /// Structure holding the resources required to operate the GPU.
> #[pin_data]
> -pub(crate) struct Gpu<'gpu> {
> +pub(crate) struct Gpu<'gpu>
> +where
> + // Hide the borrowed memory manager's resource lifetime so `Gpu` remains covariant.
> + exists<'gpu_mm>: 'gpu,
> +{
> pub(crate) spec: Spec,
> /// GSP event interrupt registration, and the enable of its subtree.
> ///
prev parent reply other threads:[~2026-11-27 0:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 22:11 [PATCH] rust: gpu: buddy: tie allocations to the allocator lifetime Danilo Krummrich
2026-11-27 0:09 ` Gary Guo [this message]
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=DN5K1U7A1D4F.SDTIDLS3S54J@garyguo.net \
--to=gary@garyguo.net \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=arunpravin.paneerselvam@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=matthew.auld@intel.com \
--cc=nova-gpu@lists.linux.dev \
--cc=simona@ffwll.ch \
/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.