From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/ttm: Introduce ttm_bo_shrink_kswap_maybe_fragmented() Date: Tue, 05 May 2026 10:13:41 +1000 Message-ID: In-Reply-To: <20260430182335.2132382-5-matthew.brost@intel.com> References: <20260430182335.2132382-1-matthew.brost@intel.com> <20260430182335.2132382-5-matthew.brost@intel.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Overall:** Clean helper that combines the kswapd check, order check, NUMA= node check, and zone fragmentation heuristic. ```c bool ttm_bo_shrink_kswap_maybe_fragmented(int nid, s8 order) { ... if (!order) return false; if (!current_is_kswapd()) return false; if (!numa_valid_node(nid)) return false; ... for (; zone_type <=3D ZONE_NORMAL; ++zone_type) { struct zone *zone =3D &NODE_DATA(nid)->node_zones[zone_type]; if (zone_maybe_fragmented_in_shrinker(zone)) return true; } return false; } ``` **Concerns:** - **Logic inversion on `order`:** The function returns `false` when `order = =3D=3D 0`. This means "order-0 reclaim is never considered fragmentation-dr= iven," which makes sense =E2=80=94 order-0 allocations can't fragment. But = it also means the function will say "maybe fragmented" for *any* non-zero o= rder (e.g., order-1), even if only order-9 allocations are causing the frag= mentation. The function doesn't compare `order` against `beneficial_order` = =E2=80=94 it simply returns true if kswapd is running, order > 0, and the z= one looks memory-rich. This seems intentionally broad but could cause the X= e shrinker to skip reclaim even when order-1 allocations genuinely need hel= p. - **Zone iteration:** The `#if IS_ENABLED(CONFIG_ZONE_DMA32)` preprocessor = check starts the loop at `ZONE_DMA32` when configured, otherwise `ZONE_NORM= AL`. The loop always goes up to `ZONE_NORMAL` inclusive. On a system with b= oth DMA32 and NORMAL zones, if *either* zone appears fragmented, the functi= on returns true. This means a fragmented DMA32 zone (which GPU drivers ofte= n care about for 32-bit DMA addresses) can cause the shrinker to skip recla= im even if NORMAL zone is fine. This seems correct for GPU workloads but wo= rth noting. - **ZONE_DMA not checked:** Systems with `CONFIG_ZONE_DMA` are not handled = =E2=80=94 the loop starts at `ZONE_DMA32` or `ZONE_NORMAL`. This is probabl= y fine since GPU allocations typically don't target the legacy DMA zone (IS= A DMA, first 16MB), but a brief comment would help. - **Missing `#include`:** The function uses `zone_maybe_fragmented_in_shrin= ker()` from `linux/vmstat.h`. I'd verify `ttm_bo_util.c` already includes `= linux/vmstat.h` or pulls it in transitively, otherwise this will fail to co= mpile. - **EXPORT_SYMBOL vs EXPORT_SYMBOL_GPL:** This exports with `EXPORT_SYMBOL`= matching `ttm_bo_shrink_avoid_wait` above it. Fine for consistency. --- Generated by Claude Code Patch Reviewer