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/panthor: Add explicit memory claim sysfs knob Date: Thu, 07 May 2026 13:42:51 +1000 Message-ID: In-Reply-To: <20260506-panthor-explicit-reclaim-v1-4-44f82ac147ce@collabora.com> References: <20260506-panthor-explicit-reclaim-v1-0-44f82ac147ce@collabora.com> <20260506-panthor-explicit-reclaim-v1-4-44f82ac147ce@collabora.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Verdict: Needs rework, same locking issues plus error handling gaps.** **Issue 1 =E2=80=94 Same `filelist_mutex` + xarray locking issues as patch = 3.** `panthor_mmu_force_claim` is also called via `panthor_run_on_pfiles_of_tgid= `, so all the locking concerns from patch 3 apply. Additionally, `drm_gpuvm= _validate` allocates memory and does page I/O (swapping pages in from disk)= , making the `filelist_mutex` hold time potentially very long. **Issue 2 =E2=80=94 Missing xarray locking and VM references:** ```c xa_for_each(&pfile->vms->xa, i, vm) { struct dma_resv *resv =3D drm_gpuvm_resv(&vm->base); dma_resv_lock(resv, NULL); ret =3D drm_gpuvm_validate(&vm->base, NULL); ... dma_resv_unlock(resv); } ``` Same as patch 3: no `xa_lock`, no VM reference. A concurrent VM destroy cou= ld free the VM (and its resv) between the `xa_for_each` yielding the entry = and `dma_resv_lock`. **Issue 3 =E2=80=94 Errors silently swallowed:** `panthor_mmu_force_claim` has return type `void`, so `mem_claim_store` has = no way to know if the swap-in failed. The sysfs documentation lists error c= odes like `-EINVAL` and `-EPERM`, but doesn't mention that the actual claim= operation could silently fail. If `drm_gpuvm_validate` fails (e.g., due to= OOM), userspace gets a success return code despite the memory not being pa= ged in. This should either return an error or the function signature should= be changed to propagate the first failure. **Issue 4 =E2=80=94 `dma_resv_lock(resv, NULL)` without deadlock avoidance:= ** Using `NULL` ticket means no deadlock avoidance with other `ww_mutex` users= . If the sysfs write races with a GPU submission that's acquiring the same = resv locks through `drm_exec`, you could get an `-EDEADLK` that isn't handl= ed. Consider using `dma_resv_lock_interruptible` at minimum. **Issue 5 =E2=80=94 Asymmetric privilege requirements:** `mem_reclaim` allows a process to reclaim its own memory without `CAP_SYS_R= ESOURCE`, but `mem_claim` always requires `CAP_SYS_RESOURCE` even for self-= claim. The documentation mentions this, but the asymmetry seems unnecessary= =E2=80=94 if a process can reclaim its own memory, why can't it claim it b= ack? The commit message says this is intentional but doesn't explain the ra= tionale. --- Generated by Claude Code Patch Reviewer