From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/shmem_helper: Make sure PMD entries get the writeable upgrade
Date: Sun, 22 Mar 2026 03:39:52 +1000 [thread overview]
Message-ID: <review-patch1-20260320151914.586945-1-boris.brezillon@collabora.com> (raw)
In-Reply-To: <20260320151914.586945-1-boris.brezillon@collabora.com>
Patch Review
**The core fix is correct.** Passing `vmf->flags & FAULT_FLAG_WRITE` to `vmf_insert_pfn_pmd()` and recording dirty/mkwrite in the PMD path addresses the issue introduced by commit 28e3918179aa.
**Bug: Error handling regression in `drm_gem_shmem_pfn_mkwrite()`.**
The original code returned `VM_FAULT_SIGBUS` on the error path:
```c
if (drm_WARN_ON(obj->dev, !shmem->pages || page_offset >= num_pages))
return VM_FAULT_SIGBUS;
```
The new `drm_gem_shmem_record_mkwrite()` is a `void` function that simply returns on the WARN path:
```c
static void drm_gem_shmem_record_mkwrite(struct vm_fault *vmf)
{
...
if (drm_WARN_ON(obj->dev, !shmem->pages || page_offset >= num_pages))
return;
...
}
```
And `drm_gem_shmem_pfn_mkwrite()` now unconditionally returns 0 (success):
```c
static vm_fault_t drm_gem_shmem_pfn_mkwrite(struct vm_fault *vmf)
{
drm_gem_shmem_record_mkwrite(vmf);
return 0;
}
```
So if the WARN fires (pages are NULL or offset is out of range), the old code signalled `VM_FAULT_SIGBUS` to userspace, but the new code silently succeeds. This should be preserved — either by making `drm_gem_shmem_record_mkwrite()` return a `vm_fault_t`, or by keeping the validation inline in `drm_gem_shmem_pfn_mkwrite()`.
**Minor: Comment style.** The multi-line comment at the PMD insertion site doesn't follow kernel style:
```c
/* Unlike PTEs which are automatically upgraded to
* writeable entries, the PMD upgrades go through
```
Kernel style uses:
```c
/*
* Unlike PTEs which are automatically upgraded to
* writeable entries, the PMD upgrades go through
```
**Locking question.** The author raises this themselves in the cover letter. `drm_gem_shmem_record_mkwrite()` accesses `shmem->pages[page_offset]` without holding `dma_resv_lock`. In the PMD path (called from `drm_gem_shmem_fault()`), the lock is already held, so it's safe. In the PTE `.pfn_mkwrite()` path, the lock is not held — but this was already the case before the patch, so it's not a regression. Still, it would be worth confirming that `shmem->pages` cannot be freed while an mmap exists (it shouldn't be, due to the `pages_use_count` refcount taken in `drm_gem_shmem_mmap()`/`vm_open()`).
**Summary:** The fix is logically correct and well-motivated. The `VM_FAULT_SIGBUS` -> silent success error handling change should be fixed before merging.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-03-21 17:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 15:19 [PATCH] drm/shmem_helper: Make sure PMD entries get the writeable upgrade Boris Brezillon
2026-03-20 16:38 ` Tommaso Merciai
2026-03-21 17:39 ` Claude review: " Claude Code Review Bot
2026-03-21 17:39 ` Claude Code Review Bot [this message]
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-20260320151914.586945-1-boris.brezillon@collabora.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