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/ttm: Use common ancestor of evictor and evictee as limit pool
Date: Sat, 14 Mar 2026 07:10:16 +1000	[thread overview]
Message-ID: <review-patch6-20260313-dmemcg-aggressive-protect-v6-6-7c71cc1492db@gmx.de> (raw)
In-Reply-To: <20260313-dmemcg-aggressive-protect-v6-6-7c71cc1492db@gmx.de>

Patch Review

This patch fixes protection calculation for sibling cgroups by using their common ancestor as the limit pool root. Without this, recursive protection propagation makes all children of a protected parent appear protected, preventing a protected sibling from evicting an unprotected sibling.

**The self-eviction guard**:
```c
if (!evict_walk->alloc_state->may_try_low &&
        bo->resource->css == evict_walk->alloc_state->charge_pool)
    return 0;
```
This prevents a protected cgroup from evicting its own buffers during the "aggressive protected" eviction path. The pointer comparison works because `charge_pool` was obtained from `get_current_dmemcs()` and `bo->resource->css` is the pool charged during allocation. However, this is a **pointer comparison** — if two different pool_state objects refer to the same cgroup (e.g., obtained at different times), this could fail to match. Looking at `dmem_cgroup_try_charge`, the pool is obtained via `get_cg_pool_unlocked` which caches pool states per cgroup, so the same cgroup should yield the same pointer. This should be safe.

**The ancestor lookup**:
```c
if (!limit_pool) {
    ancestor = dmem_cgroup_get_common_ancestor(bo->resource->css,
                           evict_walk->alloc_state->charge_pool);
    limit_pool = ancestor;
}
```
When there's no explicit limit_pool (the aggressive protection path), the common ancestor is computed per-eviction-candidate. This is O(depth) per candidate, which seems acceptable for typical cgroup hierarchies. The reference is properly put after the `dmem_cgroup_state_evict_valuable` call.

**Indentation**: The `&&` continuation at line 1852 uses tabs for alignment rather than aligning under the `(`. This may or may not match local style; the existing code in this file seems to use tab-based continuation which is kernel style.

Overall this is a well-thought-out series. The main actionable items are:
1. The `@b: First pool` → `@b: Second pool` typo in patch 2
2. The potential RCU concern around `cgroup_e_css()` usage in `dmem_cgroup_get_common_ancestor()` in patch 2
3. The "pendant" → "counterpart" wording in patch 1

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-03-13 21:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 11:39 [PATCH v6 0/6] cgroup/dmem,drm/ttm: Improve protection in contended cases Natalie Vock
2026-03-13 11:40 ` [PATCH v6 1/6] cgroup/dmem: Add queries for protection values Natalie Vock
2026-03-13 21:10   ` Claude review: " Claude Code Review Bot
2026-03-13 11:40 ` [PATCH v6 2/6] cgroup,cgroup/dmem: Add (dmem_)cgroup_common_ancestor helper Natalie Vock
2026-03-13 14:16   ` Michal Koutný
2026-03-13 21:10   ` Claude review: " Claude Code Review Bot
2026-03-13 11:40 ` [PATCH v6 3/6] drm/ttm: Extract code for attempting allocation in a place Natalie Vock
2026-03-13 21:10   ` Claude review: " Claude Code Review Bot
2026-03-13 11:40 ` [PATCH v6 4/6] drm/ttm: Split cgroup charge and resource allocation Natalie Vock
2026-03-13 12:53   ` Tvrtko Ursulin
2026-03-13 21:10   ` Claude review: " Claude Code Review Bot
2026-03-13 11:40 ` [PATCH v6 5/6] drm/ttm: Be more aggressive when allocating below protection limit Natalie Vock
2026-03-13 13:29   ` Tvrtko Ursulin
2026-03-13 21:10   ` Claude review: " Claude Code Review Bot
2026-03-13 11:40 ` [PATCH v6 6/6] drm/ttm: Use common ancestor of evictor and evictee as limit pool Natalie Vock
2026-03-13 14:11   ` Tvrtko Ursulin
2026-03-13 14:16   ` Michal Koutný
2026-03-13 21:10   ` Claude Code Review Bot [this message]
2026-03-13 21:10 ` Claude review: cgroup/dmem,drm/ttm: Improve protection in contended cases Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-02 12:37 [PATCH v5 0/6] " Natalie Vock
2026-03-02 12:37 ` [PATCH v5 6/6] drm/ttm: Use common ancestor of evictor and evictee as limit pool Natalie Vock
2026-03-03  3:29   ` Claude review: " Claude Code Review Bot
2026-02-25 12:10 [PATCH v4 0/6] cgroup/dmem,drm/ttm: Improve protection in contended cases Natalie Vock
2026-02-25 12:10 ` [PATCH v4 6/6] drm/ttm: Use common ancestor of evictor and evictee as limit pool Natalie Vock
2026-02-27  3:36   ` Claude review: " 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-patch6-20260313-dmemcg-aggressive-protect-v6-6-7c71cc1492db@gmx.de \
    --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