From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: lib: test_hmm: Implement a device release method
Date: Tue, 31 Mar 2026 16:41:10 +1000 [thread overview]
Message-ID: <review-patch3-20260331063445.3551404-4-apopple@nvidia.com> (raw)
In-Reply-To: <20260331063445.3551404-4-apopple@nvidia.com>
Patch Review
**Good fix for the warning.** The release method is correctly wired up.
**Reordering of dmirror_allocate_chunk before cdev_device_add is a nice improvement:**
```c
/* Build a list of free ZONE_DEVICE struct pages */
ret = dmirror_allocate_chunk(mdevice, NULL, false);
if (ret)
goto put_device;
ret = cdev_device_add(&mdevice->cdevice, &mdevice->device);
if (ret)
goto put_device;
```
Previously, `dmirror_allocate_chunk` was called *after* `cdev_device_add`, meaning if allocation failed, `cdev_device_del()` was never called — the device was added but not properly removed. The new ordering is better: allocate resources first, only then expose the device. The `put_device` error path now correctly triggers `dmirror_device_release()` which calls `dmirror_device_remove_chunks()`, and `dmirror_device_remove_chunks()` safely handles the case where chunks haven't been allocated (the `if (mdevice->devmem_chunks)` guard).
**One subtle concern:** After the reorder, if `cdev_device_add()` fails, `put_device()` triggers `dmirror_device_release()` → `dmirror_device_remove_chunks()`. The `remove_chunks` function calls `dmirror_device_evict_chunk()` on each chunk. Since the device was never made visible (no `cdev_device_add`), no user could have migrated pages to the device memory, so the eviction should find no migrated pages and be harmless. This is safe.
**Overall:** Clean and correct. The error-handling improvement is a nice side-fix.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-31 6:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 6:34 [PATCH 0/3] Minor hmm_test fixes and cleanups Alistair Popple
2026-03-31 6:34 ` [PATCH 1/3] lib: test_hmm: evict device pages on file close to avoid use-after-free Alistair Popple
2026-03-31 6:41 ` Claude review: " Claude Code Review Bot
2026-03-31 6:34 ` [PATCH 2/3] selftests/mm: hmm-tests: don't hardcode THP size to 2MB Alistair Popple
2026-03-31 6:41 ` Claude review: " Claude Code Review Bot
2026-03-31 6:34 ` [PATCH 3/3] lib: test_hmm: Implement a device release method Alistair Popple
2026-03-31 6:41 ` Claude Code Review Bot [this message]
2026-03-31 6:41 ` Claude review: Minor hmm_test fixes and cleanups 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-20260331063445.3551404-4-apopple@nvidia.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