public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] nouveau/vmm: use kzalloc_flex
@ 2026-03-12 19:55 Rosen Penev
  2026-03-13  3:50 ` Claude review: " Claude Code Review Bot
  2026-03-13  3:50 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-03-12 19:55 UTC (permalink / raw)
  To: dri-devel
  Cc: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS

Use the proper macro do to these sizeof calculations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
index 958fd78080bd..b9648290dffb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
@@ -53,7 +53,7 @@ nvkm_vmm_pt_new(const struct nvkm_vmm_desc *desc, bool sparse,
 		}
 	}
 
-	if (!(pgt = kzalloc(sizeof(*pgt) + (sizeof(pgt->pte[0]) * lpte), GFP_KERNEL)))
+	if (!(pgt = kzalloc_flex(*pgt, pte, lpte)))
 		return NULL;
 	pgt->page = page ? page->shift : 0;
 	pgt->sparse = sparse;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Claude review: nouveau/vmm: use kzalloc_flex
  2026-03-12 19:55 [PATCH] nouveau/vmm: use kzalloc_flex Rosen Penev
  2026-03-13  3:50 ` Claude review: " Claude Code Review Bot
@ 2026-03-13  3:50 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13  3:50 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: nouveau/vmm: use kzalloc_flex
Author: Rosen Penev <rosenp@gmail.com>
Patches: 1
Reviewed: 2026-03-13T13:50:17.120409

---

This is a single-patch series that converts a manual `kzalloc(sizeof(...) + sizeof(...) * count)` pattern to the newer `kzalloc_flex()` macro in the nouveau VMM code. The change is straightforward and correct.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Claude review: nouveau/vmm: use kzalloc_flex
  2026-03-12 19:55 [PATCH] nouveau/vmm: use kzalloc_flex Rosen Penev
@ 2026-03-13  3:50 ` Claude Code Review Bot
  2026-03-13  3:50 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13  3:50 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: OK**

The original code:
```c
if (!(pgt = kzalloc(sizeof(*pgt) + (sizeof(pgt->pte[0]) * lpte), GFP_KERNEL)))
```

is replaced with:
```c
if (!(pgt = kzalloc_flex(*pgt, pte, lpte)))
```

This is correct because:

1. `struct nvkm_vmm_pt` (defined in `vmm.h:18`) has a flexible array member `union nvkm_pte_tracker pte[]` at `vmm.h:58`, and the macro's `FAM` argument is `pte` — matching correctly.
2. `kzalloc_flex` expands to `__alloc_flex(kzalloc, default_gfp(), typeof(*pgt), pte, lpte)`, which uses `struct_size_t()` internally to compute the same `sizeof(*pgt) + sizeof(pgt->pte[0]) * lpte` size.
3. `default_gfp()` with no extra arguments resolves to `GFP_KERNEL` (via `include/linux/gfp.h:18`), matching the original explicit `GFP_KERNEL`.
4. The `__alloc_flex` macro at `slab.h:990` also handles `__counted_by()` annotation tracking if present, which is a bonus.

**Minor nit on commit message:** The commit message says "Use the proper macro do to these sizeof calculations" — there's a typo: "do to" should be "to do". Very minor, but worth fixing before applying.

**Verdict:** The patch is correct and a clean mechanical conversion. Recommend applying with the typo fix in the commit message.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-13  3:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 19:55 [PATCH] nouveau/vmm: use kzalloc_flex Rosen Penev
2026-03-13  3:50 ` Claude review: " Claude Code Review Bot
2026-03-13  3:50 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox