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: Thu, 23 Apr 2026 09:01:58 +1000 [thread overview]
Message-ID: <review-patch1-20260421012608.1474950-2-matthew.brost@intel.com> (raw)
In-Reply-To: <20260421012608.1474950-2-matthew.brost@intel.com>
Patch Review
This patch changes the reclaim behavior in `ttm_pool_alloc_page()` for non-beneficial orders.
**The change:**
```c
- if (beneficial_order && order > beneficial_order)
- gfp_flags &= ~__GFP_DIRECT_RECLAIM;
+ if (order && beneficial_order && order != beneficial_order)
+ gfp_flags &= ~__GFP_RECLAIM;
```
There are two distinct changes here that should be clearly called out:
**1. Condition broadened from `order > beneficial_order` to `order != beneficial_order`:**
The old code only disabled reclaim for orders *above* beneficial_order. The new code also disables reclaim for orders *below* beneficial_order (e.g., orders 1-8 when beneficial_order is 9). The rationale in the commit message — "issuing direct reclaim or triggering kswap at a lower order than beneficial_order is ineffective, since the driver does not benefit from reclaiming lower-order pages" — is correct but understates the significance. This is a meaningful behavioral change for the entire fallback path.
Looking at the allocation loop in `__ttm_pool_alloc()` (ttm_pool.c:786-829), when order-9 allocation fails, the allocator falls back through orders 8, 7, ... 1, 0. Under the old code, these fallback orders would still trigger reclaim. Under the new code, only order 0 retains reclaim. This is correct in the fragmentation scenario (plenty of free pages, just not contiguous), but worth verifying that it doesn't hurt the genuine-memory-pressure scenario where even order-0 allocations are tight.
In the genuine pressure case: order 9 with `__GFP_NORETRY` would attempt limited reclaim and fail, orders 8-1 would fail immediately (no reclaim), and order 0 would succeed with full reclaim (no `__GFP_NORETRY`, full `__GFP_RECLAIM`). This seems acceptable since order-0 is the ultimate fallback and handles true pressure.
**2. Flag change from `~__GFP_DIRECT_RECLAIM` to `~__GFP_RECLAIM`:**
`__GFP_RECLAIM` is `__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM` (gfp_types.h:259). The old code only disabled synchronous direct reclaim but still allowed waking kswapd. The new code disables *both*. This is more aggressive — non-beneficial-order allocations won't even wake kswapd. The commit message says "direct reclaim should only be issued with __GFP_NORETRY at exactly beneficial_order" but doesn't explicitly mention that kswapd wakeup is also now suppressed for all non-beneficial orders.
**Suggestion:** The commit message should explicitly call out both changes: (a) reclaim is now disabled for orders *below* beneficial_order (not just above), and (b) kswapd wakeup is also suppressed (not just direct reclaim). These are individually defensible but together represent a substantially more aggressive policy than the old code.
**Minor nit:** The existing comment above this code says "device tolds us" — pre-existing typo, but if you're touching adjacent lines, consider fixing to "device told us".
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-22 23:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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-21 6:11 ` Christian König
2026-04-22 4:12 ` Matthew Brost
2026-04-22 6:41 ` Christian König
2026-04-22 7:32 ` Tvrtko Ursulin
2026-04-22 7:41 ` Christian König
2026-04-22 20:41 ` Matthew Brost
2026-04-22 23:01 ` Claude Code Review Bot [this message]
2026-04-21 1:26 ` [PATCH 2/3] drm/xe: Set TTM device beneficial_order to 9 (2M) Matthew Brost
2026-04-22 23:01 ` Claude review: " Claude Code Review Bot
2026-04-21 1:26 ` [PATCH 3/3] drm/xe: Avoid shrinker reclaim from kswapd under fragmentation Matthew Brost
2026-04-22 8:22 ` Thomas Hellström
2026-04-22 20:27 ` Matthew Brost
2026-04-22 23:01 ` Claude review: " Claude Code Review Bot
2026-04-22 23:01 ` Claude review: drm/ttm, drm/xe: Avoid reclaim/eviction loops " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-04-30 18:23 [PATCH v3 0/6] mm, " 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-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 3/6] drm/ttm: Issue direct reclaim at beneficial_order 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-patch1-20260421012608.1474950-2-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