From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/ttm/tests: add a test to exercise ttm_bo_swapout
Date: Mon, 09 Mar 2026 08:23:09 +1000 [thread overview]
Message-ID: <review-patch1-20260306-ttm_bo_swapout_test-v1-1-aaab11091ee0@igalia.com> (raw)
In-Reply-To: <20260306-ttm_bo_swapout_test-v1-1-aaab11091ee0@igalia.com>
Patch Review
**Positive aspects:**
- Well-written commit message with clear motivation and historical context.
- The test follows the established patterns in `ttm_bo_validate_test.c` (same allocation style, same cleanup pattern with `ttm_bo_fini`/`ttm_mock_manager_fini`).
- Good validation: checks the return value, the resulting mem_type, and the swapped flag.
**Minor observations:**
1. **`KUNIT_EXPECT_EQ` vs `KUNIT_ASSERT_EQ` for `ttm_bo_init_reserved` failure** (line 791):
```c
KUNIT_EXPECT_EQ(test, err, 0);
```
If `ttm_bo_init_reserved` fails, the test continues and will likely crash on the subsequent `dma_resv_unlock` and `ttm_bo_swapout` calls with an uninitialized BO. Using `KUNIT_ASSERT_EQ` would abort the test on failure, preventing cascading issues. That said, the existing tests in this file all use `KUNIT_EXPECT_EQ` for this same check (e.g., lines 129, 178, 220, 252), so this is consistent with the existing code style. It could be argued the existing tests all have this same weakness, but that's a separate cleanup.
2. **Potential NULL dereference in assertions after swapout** (lines 796-797):
```c
KUNIT_EXPECT_EQ(test, bo->resource->mem_type, TTM_PL_SYSTEM);
KUNIT_EXPECT_TRUE(test, bo->ttm->page_flags & TTM_TT_FLAG_SWAPPED);
```
If `ttm_bo_swapout` fails or doesn't behave as expected, `bo->resource` or `bo->ttm` could potentially be NULL. A defensive check or using `KUNIT_ASSERT_NOT_NULL` before dereferencing would be safer. However, in practice, a failed swapout would likely leave these pointers valid (just not in the expected state), so this is a minor robustness concern rather than a real bug.
3. **Checking swapped return value** (line 794-795):
```c
swapped = ttm_bo_swapout(priv->ttm_dev, &ctx_init, man, GFP_KERNEL, 1);
KUNIT_EXPECT_EQ(test, swapped, MANAGER_SIZE / PAGE_SIZE);
```
The `MANAGER_SIZE / PAGE_SIZE` expectation is consistent with having initialized the GEM object with size `MANAGER_SIZE` at line 787. This looks correct.
4. **Cleanup ordering**: The test calls `ttm_bo_fini(bo)` before `ttm_mock_manager_fini(priv->ttm_dev, mem_type)`, which is the correct order (destroy BO before tearing down the manager). This matches the pattern in other tests like `ttm_bo_validate_move_fence_not_signaled` at lines 757-759.
**Overall:** The patch is straightforward, well-structured, and follows the existing conventions. The observations above are all minor. The test provides useful coverage for `ttm_bo_swapout` that was previously missing.
**Reviewed-by worthy** with no blocking issues.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-08 22:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 18:00 [PATCH] drm/ttm/tests: add a test to exercise ttm_bo_swapout Thadeu Lima de Souza Cascardo
2026-03-08 22:23 ` Claude Code Review Bot [this message]
2026-03-08 22:23 ` Claude review: " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-03-09 18:47 [PATCH v2] " Thadeu Lima de Souza Cascardo
2026-03-10 2:02 ` Claude review: " Claude Code Review Bot
2026-03-10 2:02 ` 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-20260306-ttm_bo_swapout_test-v1-1-aaab11091ee0@igalia.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