From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/ttm: Issue direct reclaim at beneficial_order
Date: Tue, 05 May 2026 10:00:00 +1000 [thread overview]
Message-ID: <review-patch3-20260430191809.2142544-4-matthew.brost@intel.com> (raw)
In-Reply-To: <20260430191809.2142544-4-matthew.brost@intel.com>
Patch Review
**Subject:** `[PATCH v4 3/6] drm/ttm: Issue direct reclaim at beneficial_order`
This patch changes how GFP flags are modified in `ttm_pool_alloc_page()`:
```c
- if (beneficial_order && order > beneficial_order)
- gfp_flags &= ~__GFP_DIRECT_RECLAIM;
+ if (order && beneficial_order && order != beneficial_order)
+ gfp_flags &= ~__GFP_RECLAIM;
```
**This patch has significant issues:**
1. **The change from `__GFP_DIRECT_RECLAIM` to `__GFP_RECLAIM` is aggressive.** `__GFP_RECLAIM` is `(__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM)`. The old code only removed direct reclaim for orders above beneficial_order, allowing kswapd to still be woken. The new code removes *all* reclaim (including kswapd wakeup) for any order that isn't exactly `beneficial_order` (and isn't 0). This means:
- Orders *below* `beneficial_order` (e.g., order 1-8 when beneficial is 9) now lose **all** reclaim, not just direct reclaim. Before, these weren't affected at all.
- Orders *above* `beneficial_order` also lose kswapd wakeup, which they didn't before.
2. **The `order != beneficial_order` condition is too broad.** The old code only penalized orders *above* beneficial_order. The new code penalizes all non-zero orders that aren't exactly equal to beneficial_order. For orders between 1 and `beneficial_order - 1`, the old code allowed normal reclaim behavior. The commit message says "issuing direct reclaim at a lower order than beneficial_order is ineffective" — but that's the driver's preferred large page size. The allocator will still try smaller orders as fallbacks (that's how the pool works — it iterates downward), and those smaller allocations should still be allowed to trigger reclaim since they may succeed where the large order failed.
3. **The commit message is misleading.** It says "direct reclaim should only be issued with `__GFP_NORETRY` at exactly beneficial_order" but the code doesn't set `__GFP_NORETRY` — it strips `__GFP_RECLAIM`. These are very different semantics. Also, `__GFP_NORETRY` is already set at line 161 for all non-zero orders:
```c
if (order)
gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN |
__GFP_THISNODE;
```
So the description of intended behavior doesn't match the implementation.
4. **The fallback to order 0 claim in the commit message** ("direct reclaim without `__GFP_NORETRY` at order 0 when failure is not an option") is handled by the `if (order && ...)` guard, which is correct.
**Recommendation: This patch needs rework.** The semantics change is too aggressive. Consider keeping `__GFP_DIRECT_RECLAIM` removal (not `__GFP_RECLAIM`) and being more precise about the order range.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-05 0:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 19:18 [PATCH v4 0/6] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Matthew Brost
2026-04-30 19:18 ` [PATCH v4 1/6] mm: Wire up order in shrink_control Matthew Brost
2026-05-05 0:00 ` Claude review: " Claude Code Review Bot
2026-04-30 19:18 ` [PATCH v4 2/6] mm: Introduce zone_maybe_fragmented_in_shrinker() Matthew Brost
2026-05-01 0:50 ` Santa, Carlos
[not found] ` <f25f27a1-bf09-44bd-9b37-49f159d82d6a@panix.com>
2026-05-01 20:00 ` PATCH v4 0/6] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Matthew Brost
[not found] ` <1bc0b1a7-a01f-4dc2-ad7a-3a05f975331e@panix.com>
2026-05-01 21:10 ` Matthew Brost
2026-05-01 22:33 ` Matthew Brost
2026-05-05 0:00 ` Claude review: mm: Introduce zone_maybe_fragmented_in_shrinker() Claude Code Review Bot
2026-04-30 19:18 ` [PATCH v4 3/6] drm/ttm: Issue direct reclaim at beneficial_order Matthew Brost
2026-05-04 7:16 ` Christian König
2026-05-05 0:00 ` Claude Code Review Bot [this message]
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
2026-04-30 19:18 ` [PATCH v4 5/6] drm/xe: Set TTM device beneficial_order to 9 (2M) Matthew Brost
2026-05-05 0:00 ` Claude review: " Claude Code Review Bot
2026-04-30 19:18 ` [PATCH v4 6/6] drm/xe: Avoid shrinker reclaim from kswapd under fragmentation Matthew Brost
2026-05-05 0:00 ` Claude review: " Claude Code Review Bot
2026-04-30 23:01 ` [PATCH v4 0/6] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops " Andrew Morton
2026-05-01 6:28 ` Matthew Brost
2026-05-01 12:51 ` Andrew Morton
2026-05-01 1:42 ` Dave Chinner
2026-05-01 7:09 ` Matthew Brost
2026-05-05 0:00 ` Claude review: " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-04-30 18:23 [PATCH v3 0/6] " Matthew Brost
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-21 1:26 [PATCH 0/3] drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Matthew Brost
2026-04-21 1:26 ` [PATCH 1/3] drm/ttm: Issue direct reclaim at beneficial_order Matthew Brost
2026-04-22 23:01 ` 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-20260430191809.2142544-4-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