public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: dma-buf: system_heap: Optimize sg_table-to-pages conversion in vmap
Date: Sun, 12 Apr 2026 14:23:03 +1000	[thread overview]
Message-ID: <review-overall-20260406214938.24142-1-baohua@kernel.org> (raw)
In-Reply-To: <20260406214938.24142-1-baohua@kernel.org>

Overall Series Review

Subject: dma-buf: system_heap: Optimize sg_table-to-pages conversion in vmap
Author: "Barry Song (Xiaomi)" <baohua@kernel.org>
Patches: 3
Reviewed: 2026-04-12T14:23:03.509679

---

This is a single-patch optimization for `system_heap_do_vmap()` in the DMA-buf system heap. The patch replaces the `for_each_sgtable_page()` iterator (which calls into `__sg_page_iter_next()` for every single page) with a nested loop that iterates over scatterlist entries and then fills pages using simple pointer arithmetic within each entry. The approach is sound and the performance improvement is plausible -- `for_each_sgtable_page()` involves non-trivial per-page overhead (function call to `__sg_page_iter_next()`, sg boundary checking, etc.) that is completely unnecessary when the caller knows each sg entry's pages are contiguous.

The optimization is **correct** for the system heap because every sg entry is created with offset=0 and length=page_size(page) (see `system_heap_allocate()` at line 394 of the current source), guaranteeing page-aligned lengths and contiguous pages within each entry.

The change to move the `WARN_ON` out of the loop and convert it from `>=` (overflow guard) to `!=` (exact match) is also a good improvement -- it catches both over-counting *and* under-counting.

**Minor issues noted below, but overall this is a clean, well-motivated optimization.**

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-04-12  4:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-06 21:49 [PATCH] dma-buf: system_heap: Optimize sg_table-to-pages conversion in vmap Barry Song (Xiaomi)
2026-04-07  7:57 ` Christian König
2026-04-07 11:29   ` Barry Song
2026-04-12  4:23 ` Claude review: " Claude Code Review Bot
2026-04-12  4:23 ` Claude Code Review Bot [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=review-overall-20260406214938.24142-1-baohua@kernel.org \
    --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