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: Insert instead of copy pages into shmem when shrinking
Date: Sat, 16 May 2026 13:43:39 +1000	[thread overview]
Message-ID: <review-overall-20260512110339.6244-1-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260512110339.6244-1-thomas.hellstrom@linux.intel.com>

Overall Series Review

Subject: Insert instead of copy pages into shmem when shrinking
Author: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= <thomas.hellstrom@linux.intel.com>
Patches: 19
Reviewed: 2026-05-16T13:43:39.916433

---

This 2-patch series from Thomas Hellström introduces a zero-copy path for TTM buffer object shrinking. Instead of allocating shmem pages and copying data into them (the current approach), TTM pages are inserted directly into the shmem page cache, avoiding both the memory overhead and the fragmentation caused by splitting high-order pages at shrink time. The motivation is sound: under memory pressure, having to allocate a full high-order page just to copy into it before freeing the original defeats the purpose of shrinking.

The architecture is clean: Patch 1 adds a general `shmem_insert_folio()` interface in mm/shmem with appropriate preconditions and assertions, and Patch 2 rewires TTM to use it. The series touches core mm code (`mm/page_alloc.c`, `mm/shmem.c`) which will require mm maintainer sign-off (Andrew Morton and/or the relevant mm reviewers are CC'd).

Both patches carry `Assisted-by: GitHub_Copilot:claude-sonnet-4.6`, indicating AI assistance in development. Given the complexity of the mm interactions and the subtlety of compound page lifecycle management, this warrants careful scrutiny — several of the issues below may reflect areas where AI-generated code follows patterns without fully accounting for the writeback protocol.

**Key concerns:**
1. The writeback path in `shmem_insert_folio()` skips `folio_clear_dirty_for_io()` and `folio_set_reclaim()` before calling `shmem_writeout()`, deviating from the protocol used both by the writeback infrastructure and by the old TTM code.
2. `undo_compound_page()` is exported globally but is a very sharp tool — it's only safe under narrow preconditions that aren't enforced at runtime.
3. The EEXIST handling in `shmem_insert_folio()` silently truncates existing content, which may mask logic bugs in callers.

---

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-05-16  3:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 11:03 [PATCH 0/2] Insert instead of copy pages into shmem when shrinking Thomas Hellström
2026-05-12 11:03 ` [PATCH 1/2] mm/shmem: add shmem_insert_folio() Thomas Hellström
2026-05-12 11:07   ` David Hildenbrand (Arm)
2026-05-12 11:31     ` Thomas Hellström
2026-05-12 20:03       ` David Hildenbrand (Arm)
2026-05-13  7:47         ` Christian König
2026-05-13  8:31           ` Thomas Hellström
2026-05-13  9:30             ` David Hildenbrand (Arm)
2026-05-13  8:37           ` David Hildenbrand (Arm)
2026-05-13  8:51             ` Thomas Hellström
2026-05-13 10:03               ` David Hildenbrand (Arm)
2026-05-13 10:37                 ` Thomas Hellström
2026-05-13 11:36                   ` David Hildenbrand (Arm)
2026-05-13 14:53                     ` Thomas Hellström
2026-05-13 19:35                       ` David Hildenbrand (Arm)
2026-05-14 10:40                         ` Thomas Hellström
2026-05-13 11:54             ` Christian König
2026-05-13 19:43               ` David Hildenbrand (Arm)
2026-05-16  3:43   ` Claude review: " Claude Code Review Bot
2026-05-12 11:03 ` [PATCH 2/2] drm/ttm: Use ttm_backup_insert_folio() for zero-copy swapout Thomas Hellström
2026-05-16  3:43   ` Claude review: " Claude Code Review Bot
2026-05-16  3:43 ` 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-overall-20260512110339.6244-1-thomas.hellstrom@linux.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