public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/shmem-helper: Fix Map huge page mapping in fault handler
Date: Mon, 16 Mar 2026 11:46:49 +1000	[thread overview]
Message-ID: <review-patch1-20260316002649.211819-1-pedrodemargomes@gmail.com> (raw)
In-Reply-To: <20260316002649.211819-1-pedrodemargomes@gmail.com>

Patch Review

**Race condition analysis is correct.** The commit message clearly explains the problem and reproducer. The Fixes tag is appropriate.

**Issue 1: Missing fallback from huge_fault to PTE mapping.**

When `.huge_fault` is called and the folio is PMD-mappable but alignment fails, the function returns `VM_FAULT_FALLBACK`. The MM layer will then call `.fault` which does PTE insertion. This is correct. However, if the folio is PMD-mappable and aligned but `vmf_insert_pfn_pmd()` itself fails (returns something other than `VM_FAULT_NOPAGE`), the error is propagated correctly too. This path looks fine.

**Issue 2: `pmd_none()` check was dropped.**

The original code had:
```c
if (aligned &&
    pmd_none(*vmf->pmd) &&
    folio_test_pmd_mappable(page_folio(page))) {
```

The new code removes the `pmd_none(*vmf->pmd)` check:
```c
if (aligned &&
    folio_test_pmd_mappable(page_folio(pages[page_offset]))) {
```

In the `.huge_fault` path, the PMD should be guaranteed to be in a suitable state by the MM layer, so dropping this check is likely fine — `vmf_insert_pfn_pmd()` handles it internally. But it's worth confirming this is intentional and that `vmf_insert_pfn_pmd` handles the non-none PMD case gracefully (returning an appropriate error rather than corrupting the page table).

**Issue 3: Needs rebase on drm-next.**

The current drm-next tree at `drivers/gpu/drm/drm_gem_shmem_helper.c:557-612` has substantially different code:
- The helper is now called `drm_gem_shmem_try_insert_pfn_pmd()` (not `drm_gem_shmem_try_map_pmd`)
- There's a `folio_mark_accessed()` call on success (line 605-606)
- A `pfn_mkwrite` handler has been added (line 648-664)
- Variable declarations differ (`page`, `folio` locals; `drm_dev` used for warnings)

The patch needs to be rebased to target the current tree.

**Issue 4: `folio_mark_accessed()` is missing from the patched code.**

The current drm-next code calls `folio_mark_accessed(folio)` on successful mapping. The patch (based on an older tree) does not include this. If this patch is meant to be backported to the older tree that didn't have it, this is fine; but when rebased on drm-next, it should be preserved.

**Minor: Subject line capitalization.** "Fix Map huge page" — the "Map" should be lowercase: "Fix map huge page mapping in fault handler" or perhaps rephrased to "Fix race between PMD and PTE fault paths".

**Overall:** The fix is correct in approach. Using `.huge_fault` for PMD-order mappings and `.fault` for PTE-order is the right way to let the MM layer serialize concurrent faults at different granularities. The patch needs a rebase onto drm-next before it can be applied.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-16  1:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16  0:26 [PATCH v3] drm/shmem-helper: Fix Map huge page mapping in fault handler Pedro Demarchi Gomes
2026-03-16  1:46 ` Claude Code Review Bot [this message]
2026-03-16  1:46 ` Claude review: " Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-13 14:17 [PATCH v2] " Pedro Demarchi Gomes
2026-03-13 20:52 ` Claude review: " Claude Code Review Bot
2026-03-13 20:52 ` 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-20260316002649.211819-1-pedrodemargomes@gmail.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