From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260406214938.24142-1-baohua@kernel.org> References: <20260406214938.24142-1-baohua@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Overall Series Review Subject: dma-buf: system_heap: Optimize sg_table-to-pages conversion in vmap Author: "Barry Song (Xiaomi)" 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