From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/ttm: Split cgroup charge and resource allocation Date: Fri, 27 Feb 2026 13:36:28 +1000 Message-ID: In-Reply-To: <20260225-dmemcg-aggressive-protect-v4-4-de847ab35184@gmx.de> References: <20260225-dmemcg-aggressive-protect-v4-0-de847ab35184@gmx.de> <20260225-dmemcg-aggressive-protect-v4-4-de847ab35184@gmx.de> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review This is an important correctness fix. The race is well-described: when char= ge and allocation are coupled, concurrent allocations from the same protect= ed cgroup can all pass the min/low check because the charge is released whe= n allocation fails, making the protection check unreliable. The new `ttm_resource_try_charge()` is clean: ```c +int ttm_resource_try_charge(struct ttm_buffer_object *bo, + const struct ttm_place *place, + struct dmem_cgroup_pool_state **ret_pool, + struct dmem_cgroup_pool_state **ret_limit_pool) ``` The ownership transfer comment is good practice: ```c + /* + * Ownership of charge_pool has been transferred to the TTM resource, + * don't make the caller think we still hold a reference to it. + */ + alloc_state->charge_pool =3D NULL; ``` The caller correctly puts `charge_pool` on all error paths (including the `= -EBUSY` path after `ttm_bo_evict_alloc` fails). In `ttm_bo_evict_cb`, the allocation during eviction now correctly passes t= he held `charge_pool`: ```c - evict_walk->res, NULL); + evict_walk->res, evict_walk->alloc_state->charge_pool); ``` **Minor commit message typo**: "at a poin where" =E2=86=92 "at a point wher= e". --- Generated by Claude Code Patch Reviewer