* [PATCH] drm: i915: use kzalloc_flex
@ 2026-06-30 1:19 Rosen Penev
2026-06-30 1:27 ` sashiko-bot
2026-07-01 20:24 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-06-30 1:19 UTC (permalink / raw)
To: dri-devel
Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
David Airlie, Simona Vetter,
intel-gfx@lists.freedesktop.org (open list:INTEL DRM I915 DRIVER (Meteor Lake, DG2 and old...), linux-kernel@vger.kernel.org (open list)
Simplifies allocations by using a flexible array member in this struct.
No need to free separately.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpu/drm/i915/gt/intel_gtt.h | 2 +-
drivers/gpu/drm/i915/gt/intel_ppgtt.c | 15 +--------------
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
index f6f223090760..49b2d2d24fd8 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -187,7 +187,7 @@ struct i915_page_table {
struct i915_page_directory {
struct i915_page_table pt;
spinlock_t lock;
- void **entry;
+ void *entry[];
};
#define __px_choose_expr(x, type, expr, other) \
diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index 72d8473a448b..20cc59a005c9 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
@@ -36,16 +36,10 @@ struct i915_page_directory *__alloc_pd(int count)
{
struct i915_page_directory *pd;
- pd = kzalloc_obj(*pd, I915_GFP_ALLOW_FAIL);
+ pd = kzalloc_flex(*pd, entry, count, I915_GFP_ALLOW_FAIL);
if (unlikely(!pd))
return NULL;
- pd->entry = kzalloc_objs(*pd->entry, count, I915_GFP_ALLOW_FAIL);
- if (unlikely(!pd->entry)) {
- kfree(pd);
- return NULL;
- }
-
spin_lock_init(&pd->lock);
return pd;
}
@@ -60,7 +54,6 @@ struct i915_page_directory *alloc_pd(struct i915_address_space *vm)
pd->pt.base = vm->alloc_pt_dma(vm, I915_GTT_PAGE_SIZE_4K);
if (IS_ERR(pd->pt.base)) {
- kfree(pd->entry);
kfree(pd);
return ERR_PTR(-ENOMEM);
}
@@ -72,12 +65,6 @@ void free_px(struct i915_address_space *vm, struct i915_page_table *pt, int lvl)
{
BUILD_BUG_ON(offsetof(struct i915_page_directory, pt));
- if (lvl) {
- struct i915_page_directory *pd =
- container_of(pt, typeof(*pd), pt);
- kfree(pd->entry);
- }
-
if (pt->base)
i915_gem_object_put(pt->base);
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm: i915: use kzalloc_flex
2026-06-30 1:19 [PATCH] drm: i915: use kzalloc_flex Rosen Penev
@ 2026-06-30 1:27 ` sashiko-bot
2026-07-01 20:24 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-06-30 1:27 UTC (permalink / raw)
To: Rosen Penev; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Flexible array conversion forces inefficient order-1 (8KB) allocations for page directories.
--
commit ed37e64eb293a3ef09353d34ef014044171cfe28
Author: Rosen Penev <rosenp@gmail.com>
drm: i915: use kzalloc_flex
This patch simplifies the allocation of i915_page_directory structures by
replacing a pointer with a flexible array member, consolidating two
allocations into one.
> diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
> index b54ee4f25af10..642b5c856a55a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gtt.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
> @@ -186,7 +186,7 @@ struct i915_page_table {
> struct i915_page_directory {
> struct i915_page_table pt;
> spinlock_t lock;
> - void **entry;
> + void *entry[];
> };
>
> #define __px_choose_expr(x, type, expr, other) \
> diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
> index 72d8473a448b9..20cc59a005c97 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
> @@ -36,16 +36,10 @@ struct i915_page_directory *__alloc_pd(int count)
> {
> struct i915_page_directory *pd;
>
> - pd = kzalloc_obj(*pd, I915_GFP_ALLOW_FAIL);
> + pd = kzalloc_flex(*pd, entry, count, I915_GFP_ALLOW_FAIL);
[Severity: High]
Does this flexible array conversion force inefficient order-1 (8KB)
allocations for page directories?
Consolidating the entry array into struct i915_page_directory pushes the
allocation size from exactly 4096 bytes (for the array) to 4128 bytes. The
base struct is roughly 32 bytes, plus 512 * 8 bytes for the flexible array.
On systems with 4KB pages (like x86), a 4128-byte request cannot be satisfied
by the kmalloc-4k cache and spills over to the kmalloc-8k cache. This requires
an order-1 page allocation, wasting 4064 bytes per page directory and
significantly increasing the risk of allocation failures under memory
fragmentation compared to the previous order-0 allocation.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630011907.1453253-1-rosenp@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* ✗ LGCI.VerificationFailed: failure for drm: i915: use kzalloc_flex
2026-06-30 1:19 [PATCH] drm: i915: use kzalloc_flex Rosen Penev
2026-06-30 1:27 ` sashiko-bot
@ 2026-07-01 20:24 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2026-07-01 20:24 UTC (permalink / raw)
To: Rosen Penev; +Cc: intel-gfx
== Series Details ==
Series: drm: i915: use kzalloc_flex
URL : https://patchwork.freedesktop.org/series/169617/
State : failure
== Summary ==
Series author address 'rosenp@gmail.com' is not on the allowlist, which prevents CI from being automatically triggered.
If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork.
Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/180290/ (on built-in)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-01 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 1:19 [PATCH] drm: i915: use kzalloc_flex Rosen Penev
2026-06-30 1:27 ` sashiko-bot
2026-07-01 20:24 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
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.