From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: gpu/buddy: Track per-order used blocks with a scoreboard
Date: Sat, 16 May 2026 14:58:08 +1000 [thread overview]
Message-ID: <review-patch3-20260511164217.150237-4-francois.dugast@intel.com> (raw)
In-Reply-To: <20260511164217.150237-4-francois.dugast@intel.com>
Patch Review
**Assessment: Correct, with one observation.**
The used scoreboard has fewer update sites than the free one because blocks can only become ALLOCATED through `mark_allocated()` and can only leave ALLOCATED through `mark_free()` or direct `gpu_block_free()` during coalescing.
| Site | Operation | Guard | Correct? |
|------|-----------|-------|----------|
| `mark_allocated()` | `used_scoreboard[order]++` | Always (block is becoming allocated) | Yes |
| `mark_free()` | `used_scoreboard[order]--` | `gpu_buddy_block_is_allocated(block)` | Yes |
| `__gpu_buddy_free()` coalesce | `used_scoreboard[order]--` | `gpu_buddy_block_is_allocated(block)` | Yes |
The guard in `mark_free()` is needed because `mark_free()` is called on blocks that were SPLIT (during `__force_merge` cleanup), not just ALLOCATED. The guard in `__gpu_buddy_free()` is needed because the block entering the coalesce loop can be either ALLOCATED (from `gpu_buddy_free_block`) or FREE (from err_undo / __force_merge paths).
I traced the full lifecycle of `gpu_buddy_free_block()` → `__gpu_buddy_free()`:
- If no coalescing: the decrement happens in `mark_free()` (at the bottom of `__gpu_buddy_free`) via the `is_allocated` guard. Correct.
- If coalescing happens: the decrement happens in the new code inside the coalesce loop body. After `gpu_block_free(block)`, `block = parent` (SPLIT state), so subsequent iterations and the final `mark_free()` do NOT double-decrement. Correct.
**Print format change:** The threshold for KiB vs MiB formatting changes from `if (free < SZ_1M)` to `if (block_size < SZ_1M)`. This is a good change — it makes the unit consistent per-order regardless of how many blocks exist, and ensures `free` and `used` values in the same line always use the same unit. But this is a user-visible output change in debugfs, so anyone scraping `/sys/kernel/debug/dri/0/tile0/vram_mm` with scripts may notice.
**Label naming nit:** `out_free_free_scoreboard` is a bit stutter-y. Something like `out_free_sb` or `out_scoreboard` would read better, but this is purely cosmetic.
**Type choice:** Both scoreboards use `u64`. Given that the maximum number of blocks at any order is bounded by `size / chunk_size` (which is also `u64`), this is appropriate and overflow-safe.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-16 4:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 16:41 [PATCH v2 0/3] gpu/buddy: Per-order free and used block scoreboards Francois Dugast
2026-05-11 16:41 ` [PATCH v2 1/3] gpu/buddy: Fix use-after-free in split_block() call sites Francois Dugast
2026-05-16 4:58 ` Claude review: " Claude Code Review Bot
2026-05-11 16:41 ` [PATCH v2 2/3] gpu/buddy: Track per-order free blocks with a scoreboard Francois Dugast
2026-05-15 15:50 ` Matthew Auld
2026-05-16 4:58 ` Claude review: " Claude Code Review Bot
2026-05-11 16:41 ` [PATCH v2 3/3] gpu/buddy: Track per-order used " Francois Dugast
2026-05-16 4:58 ` Claude Code Review Bot [this message]
2026-05-16 4:58 ` Claude review: gpu/buddy: Per-order free and used block scoreboards Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-04 13:52 [PATCH 0/2] " Francois Dugast
2026-05-04 13:52 ` [PATCH 2/2] gpu/buddy: Track per-order used blocks with a scoreboard Francois Dugast
2026-05-04 22:19 ` Claude review: " Claude Code Review Bot
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=review-patch3-20260511164217.150237-4-francois.dugast@intel.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/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