Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4002E9536D for ; Wed, 4 Feb 2026 10:24:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47D6410E5AF; Wed, 4 Feb 2026 10:24:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E88C10E5AF for ; Wed, 4 Feb 2026 10:24:48 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 159CC339; Wed, 4 Feb 2026 02:24:41 -0800 (PST) Received: from [10.57.54.249] (unknown [10.57.54.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EAB983F632; Wed, 4 Feb 2026 02:24:42 -0800 (PST) Message-ID: <20026be6-1a2b-4b79-902c-94300d781fdb@arm.com> Date: Wed, 4 Feb 2026 10:24:40 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 8/8] drm/panthor: Add a GEM shrinker To: Boris Brezillon , Akash Goel Cc: Liviu Dudau , =?UTF-8?Q?Adri=C3=A1n_Larumbe?= , dri-devel@lists.freedesktop.org, David Airlie , Simona Vetter , Rob Clark , Sean Paul , Konrad Dybcio , Akhil P Oommen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Dmitry Osipenko , Chris Diamand , Danilo Krummrich , Matthew Brost , =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , Alice Ryhl , kernel@collabora.com, nd@arm.com References: <20260202113607.1745667-1-boris.brezillon@collabora.com> <20260202113607.1745667-9-boris.brezillon@collabora.com> <31c3f2bf-e530-45ae-900e-4e25db54f367@arm.com> <20260203090912.10b4e6bc@fedora> From: Steven Price Content-Language: en-GB In-Reply-To: <20260203090912.10b4e6bc@fedora> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 03/02/2026 08:09, Boris Brezillon wrote: > On Mon, 2 Feb 2026 20:08:30 +0000 > Akash Goel wrote: > >>>> +bool panthor_gem_try_evict(struct drm_gem_object *obj, >>>> + struct ww_acquire_ctx *ticket) >>> >>> I think this could be static - I don't see any reference outside this >>> file (other than the header). > > Will do. > >>> >>>> +{ >>>> + /* >>>> + * Track last locked entry for unwinding locks in error and >>>> + * success paths >>>> + */ >>>> + struct panthor_gem_object *bo = to_panthor_bo(obj); >>>> + struct drm_gpuvm_bo *vm_bo, *last_locked = NULL; >>>> + enum panthor_gem_reclaim_state old_state; >>>> + int ret = 0; >>>> + >>>> + /* To avoid potential lock ordering issue between bo_gpuva and >>>> + * mapping->i_mmap_rwsem, unmap the pages from CPU side before >>>> + * acquring the bo_gpuva lock. As the bo_resv lock is held, CPU >>>> + * page fault handler won't be able to map in the pages whilst >>>> + * eviction is in progress. >>>> + */ >>>> + drm_vma_node_unmap(&bo->base.vma_node, bo->base.dev->anon_inode->i_mapping); >>> >>> There might be an issue here - drm_gem_lru_scan() will have taken the >>> resv lock. drm_vma_node_unmap() could cause a callback to >>> panthor_vm_close(). If that ends up being the last reference to >>> bo->cmap.mmap_count then we'll deadlock attempting to aquire the resv >>> lock again. >> >> Actually drm_vma_node_unmap() would just invalidate the CPU PTEs. >> The CPU mapping won't be removed and so panthor_vm_close() won't get called. > > Yep, that's also my understanding of drm_vma_node_unmap(): it kills the > relevant PTEs in the user VM, but leave the VMA active, so next time > there's an access, the fault handler will be called. > >> >>> >>> I not 100% on that, and sadly it seems my test setup has died so I can't >>> test that out today. >>> >> >> We have tests that tries to trigger an evicition for a CPU mapped BO and >> so far we didn't see a deadlock problem. > > Actually, that's one of the very few tests I have in my igt branch [1], > and it was passing fine. > > [1]https://gitlab.freedesktop.org/bbrezillon/igt-gpu-tools/-/commit/fc76934a5579767d2aabe787d40e38a17c3f4ea4#67d3c5d7df01192b03c20b43ad33249c663a95f5_80_97 Cool - I was going to test this out, but I was working at home and my machine in the office decided to lose its USB devices so I couldn't get my board working. The joys of working in two different locations. Anyway, with that resolved, it looks good to me. So with that minor change to panthor_gem_try_evict() you have my: Reviewed-by: Steven Price Thanks, Steve