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: drm/ttm: Introduce ttm_bo_shrink_kswap_maybe_fragmented()
Date: Tue, 05 May 2026 10:13:41 +1000	[thread overview]
Message-ID: <review-patch4-20260430182335.2132382-5-matthew.brost@intel.com> (raw)
In-Reply-To: <20260430182335.2132382-5-matthew.brost@intel.com>

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 <= ZONE_NORMAL; ++zone_type) {
        struct zone *zone = &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 == 0`. This means "order-0 reclaim is never considered fragmentation-driven," which makes sense — order-0 allocations can't fragment. But it also means the function will say "maybe fragmented" for *any* non-zero order (e.g., order-1), even if only order-9 allocations are causing the fragmentation. The function doesn't compare `order` against `beneficial_order` — it simply returns true if kswapd is running, order > 0, and the zone looks memory-rich. This seems intentionally broad but could cause the Xe shrinker to skip reclaim even when order-1 allocations genuinely need help.

- **Zone iteration:** The `#if IS_ENABLED(CONFIG_ZONE_DMA32)` preprocessor check starts the loop at `ZONE_DMA32` when configured, otherwise `ZONE_NORMAL`. The loop always goes up to `ZONE_NORMAL` inclusive. On a system with both DMA32 and NORMAL zones, if *either* zone appears fragmented, the function returns true. This means a fragmented DMA32 zone (which GPU drivers often care about for 32-bit DMA addresses) can cause the shrinker to skip reclaim even if NORMAL zone is fine. This seems correct for GPU workloads but worth noting.

- **ZONE_DMA not checked:** Systems with `CONFIG_ZONE_DMA` are not handled — the loop starts at `ZONE_DMA32` or `ZONE_NORMAL`. This is probably fine since GPU allocations typically don't target the legacy DMA zone (ISA DMA, first 16MB), but a brief comment would help.

- **Missing `#include`:** The function uses `zone_maybe_fragmented_in_shrinker()` 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 compile.

- **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

  reply	other threads:[~2026-05-05  0:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 18:23 [PATCH v3 0/6] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Matthew Brost
2026-04-30 18:23 ` [PATCH v3 1/6] mm: Wire up order in shrink_control Matthew Brost
2026-05-05  0:13   ` Claude review: " Claude Code Review Bot
2026-04-30 18:23 ` [PATCH v3 2/6] mm: Introduce zone_maybe_fragmented_in_shrinker() Matthew Brost
2026-05-05  0:13   ` Claude review: " Claude Code Review Bot
2026-04-30 18:23 ` [PATCH v3 3/6] drm/ttm: Issue direct reclaim at beneficial_order Matthew Brost
2026-05-05  0:13   ` Claude review: " Claude Code Review Bot
2026-04-30 18:23 ` [PATCH v3 4/6] drm/ttm: Introduce ttm_bo_shrink_kswap_maybe_fragmented() Matthew Brost
2026-05-05  0:13   ` Claude Code Review Bot [this message]
2026-04-30 18:23 ` [PATCH v3 5/6] drm/xe: Set TTM device beneficial_order to 9 (2M) Matthew Brost
2026-05-05  0:13   ` Claude review: " Claude Code Review Bot
2026-04-30 18:23 ` [PATCH v3 6/6] drm/xe: Avoid shrinker reclaim from kswapd under fragmentation Matthew Brost
2026-05-05  0:13   ` Claude review: " Claude Code Review Bot
2026-05-05  0:13 ` Claude review: mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops " Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-30 19:18 [PATCH v4 0/6] " Matthew Brost
2026-04-30 19:18 ` [PATCH v4 4/6] drm/ttm: Introduce ttm_bo_shrink_kswap_maybe_fragmented() Matthew Brost
2026-05-05  0:00   ` 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-patch4-20260430182335.2132382-5-matthew.brost@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