From: sashiko-bot@kernel.org
To: "Jim Cromie" <jim.cromie@gmail.com>
Cc: dri-devel@lists.freedesktop.org, bpf@vger.kernel.org
Subject: Re: [PATCH 4/9] drm/gpuvm: Route gpuva_op allocations to folio_scratchpad
Date: Mon, 17 Aug 2026 17:31:50 +0000 [thread overview]
Message-ID: <20260817173150.D1C311F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817-folio-pool-v1-v1-4-0c1d230aa3af@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unbounded memory leak of transient `struct drm_gpuva_op` objects due to bump allocator usage without intermediate resets.
- [Low] Undeclared static key variable 'gpuvm_scratchpad_key' used in drm_gpuvm_init().
--
--- Patch [4]: [PATCH 4/9] drm/gpuvm: Route gpuva_op allocations to folio_scratchpad ---
commit 6e27181fef6cb87688764c9745ab2086b2091e88
Author: Jim Cromie <jim.cromie@gmail.com>
Subject: drm/gpuvm: Route gpuva_op allocations to folio_scratchpad
This commit modifies the DRM GPUVM subsystem to route default gpuva_op
allocations to a folio scratchpad embedded in struct drm_gpuvm. It updates
gpuva_op_alloc() to use folio_scratchpad_alloc_obj() and handles the bulk
teardown during drm_gpuvm_fini().
> diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c
> --- a/drivers/gpu/drm/drm_gpuvm.c
> +++ b/drivers/gpu/drm/drm_gpuvm.c
> @@ -1109,6 +1109,8 @@ drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name,
> spin_lock_init(&gpuvm->evict.lock);
>
> init_llist_head(&gpuvm->bo_defer);
> + folio_scratchpad_init_key(&gpuvm->va_scratchpad, get_order(SZ_64K),
> + &gpuvm_scratchpad_key);
[Severity: Low]
Does this cause a compilation failure?
In drm_gpuvm_init(), the code references gpuvm_scratchpad_key, but this
static key is not defined until later in the file via the
DEFINE_FOLIO_POOL_STATIC_KEY_PARAM macro.
[ ... ]
> @@ -2814,7 +2820,8 @@ gpuva_op_alloc(struct drm_gpuvm *gpuvm)
> if (fn && fn->op_alloc)
> op = fn->op_alloc();
> else
> - op = kzalloc_obj(*op);
> + op = folio_scratchpad_alloc_obj(gpuvm, va_scratchpad,
> + struct drm_gpuva_op, GFP_KERNEL);
>
> if (unlikely(!op))
> return NULL;
> @@ -2831,7 +2838,7 @@ gpuva_op_free(struct drm_gpuvm *gpuvm,
> if (fn && fn->op_free)
> fn->op_free(op);
> else
> - kfree(op);
> + folio_scratchpad_free_elem(op);
> }
[Severity: High]
Will this cause an unbounded memory leak for long-lived VMs?
In gpuva_op_alloc(), struct drm_gpuva_op objects are allocated using
gpuvm->va_scratchpad, which acts as a bump allocator. However, the
folio_scratchpad_free_elem() called here in gpuva_op_free() cannot reclaim
individual elements from a scratchpad bump allocator.
Since the memory is only fully reclaimed during bulk teardown in
drm_gpuvm_fini(), and these objects are transiently allocated per map/unmap
operation, could this result in continuous memory leakage over the lifetime
of the GPU VM?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260817-folio-pool-v1-v1-0-0c1d230aa3af@gmail.com?part=4
next prev parent reply other threads:[~2026-08-17 17:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 17:22 [PATCH 0/9] lib/folio_pool: Direct-Map Large Folio Pool & Scratchpad bump allocators Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 1/9] lib/folio_pool: Introduce " Jim Cromie via B4 Relay
2026-08-17 17:33 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 2/9] netfilter/nf_tables: Add folio_scratchpad collector to struct nftables_pernet Jim Cromie via B4 Relay
2026-08-17 17:35 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 3/9] bpf/verifier: Route verifier stack state node allocations to folio_pool Jim Cromie via B4 Relay
2026-08-17 17:35 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 4/9] drm/gpuvm: Route gpuva_op allocations to folio_scratchpad Jim Cromie via B4 Relay
2026-08-17 17:31 ` sashiko-bot [this message]
2026-08-17 17:22 ` [PATCH 5/9] bpf/syscall: Route generic_map_update_batch key/value " Jim Cromie via B4 Relay
2026-08-17 17:32 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 6/9] locking/lockdep: Fallback to folio_pool in alloc_list_entry when static pool is full Jim Cromie via B4 Relay
2026-08-17 17:36 ` sashiko-bot
2026-08-17 21:01 ` Peter Zijlstra
2026-08-17 17:22 ` [PATCH 7/9] locking/lockdep: Traverse adjacency lists directly in zap_class() Jim Cromie via B4 Relay
2026-08-17 17:39 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 8/9] locking/lockdep: Shrink static list_entries array to early bootstrap buffer Jim Cromie via B4 Relay
2026-08-17 17:52 ` sashiko-bot
2026-08-17 17:22 ` [PATCH 9/9] locking/lockdep: Migrate and compact boot-time dependency graph from __initdata Jim Cromie via B4 Relay
2026-08-17 17:45 ` sashiko-bot
2026-08-17 18:17 ` [PATCH 0/9] lib/folio_pool: Direct-Map Large Folio Pool & Scratchpad bump allocators David Hildenbrand (Arm)
2026-08-17 18:34 ` Matthew Wilcox
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=20260817173150.D1C311F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jim.cromie@gmail.com \
--cc=sashiko-reviews@lists.linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox