From mboxrd@z Thu Jan 1 00:00:00 1970 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 B3F2CEF48C9 for ; Mon, 16 Feb 2026 08:51:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22BE910E0B0; Mon, 16 Feb 2026 08:51:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="lsB5/U5X"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C44E610E0B0 for ; Mon, 16 Feb 2026 08:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1771231875; bh=0GAZUpmOR2HUnzIZWBgRgIowoiwTceuDp8ETqOk43xQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lsB5/U5XXJEPK4WZ2jjJDx8oztnLX1W51m1hdem6hxRaP5BX9pE4BYEdaOS7S3upo ivQa9tep8Fjw6KQKGh6/VYT4FNXmLoMWBE8AOXo2Zt9odOcuj90ulxDryz6lztn+qS nAq3yr63ioIWAOW1TnTi6P76hLyNO6/oIwYQFjg5TY/v1z1wgyAJvWwUmkS8hhnwtQ avLoBtGtommerIPxmpsjJIWHbN15uABCj91QSiCBuaVm/L0f2GC0Vltrp5K5ozWBEk bgDXK3r9iWT1K6dXsNzsZMty8HtJWGR0Cix8zeVS6f+UmI8FG0E3ejGeeAiHQls+l8 eVQXOJCi00kEQ== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:d919:a6e:5ea1:8a9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id B91E217E150E; Mon, 16 Feb 2026 09:51:14 +0100 (CET) Date: Mon, 16 Feb 2026 09:51:10 +0100 From: Boris Brezillon To: Chia-I Wu Cc: Steven Price , Liviu Dudau , =?UTF-8?B?QWRyacOhbg==?= Larumbe , dri-devel@lists.freedesktop.org, David Airlie , Simona Vetter , Akash Goel , Rob Clark , Sean Paul , Konrad Dybcio , Akhil P Oommen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Dmitry Osipenko , Chris Diamand , Danilo Krummrich , Matthew Brost , Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , Alice Ryhl , kernel@collabora.com Subject: Re: [PATCH v3 9/9] drm/panthor: Add a GEM shrinker Message-ID: <20260216095110.324c0cde@fedora> In-Reply-To: References: <20260211080343.1887134-1-boris.brezillon@collabora.com> <20260211080343.1887134-10-boris.brezillon@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Thu, 12 Feb 2026 17:19:20 -0800 Chia-I Wu wrote: > On Wed, Feb 11, 2026 at 12:22=E2=80=AFAM Boris Brezillon > wrote: > [...] > > +static unsigned long > > +panthor_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_con= trol *sc) > > +{ > > + struct panthor_device *ptdev =3D shrinker->private_data; > > + unsigned long remaining =3D 0; > > + unsigned long freed =3D 0; > > + > > + if (!can_swap()) > > + goto out; > > + > > + freed +=3D drm_gem_lru_scan(&ptdev->reclaim.unused, > > + sc->nr_to_scan - freed, &remaining, > > + panthor_gem_try_evict, NULL); > > + if (freed >=3D sc->nr_to_scan) > > + goto out; > > + > > + freed +=3D drm_gem_lru_scan(&ptdev->reclaim.mmapped, > > + sc->nr_to_scan - freed, &remaining, > > + panthor_gem_try_evict, NULL); > > + if (freed >=3D sc->nr_to_scan) > > + goto out; > > + =20 > Do we need to check for can_block here? panthor_gem_try_evict will > block for bos on lrus below. Yep, we do. Will fix that in v4. >=20 >=20 > > + freed +=3D panthor_mmu_reclaim_priv_bos(ptdev, sc->nr_to_scan -= freed, > > + &remaining, panthor_gem_t= ry_evict); > > + if (freed >=3D sc->nr_to_scan) > > + goto out; > > + > > + freed +=3D drm_gem_lru_scan(&ptdev->reclaim.gpu_mapped_shared, > > + sc->nr_to_scan - freed, &remaining, > > + panthor_gem_try_evict, NULL); > > + > > +out: > > +#ifdef CONFIG_DEBUG_FS > > + /* This is racy, but that's okay, because this is just debugfs > > + * reporting and doesn't need to be accurate. > > + */ > > + ptdev->reclaim.nr_pages_reclaimed_on_last_scan =3D freed; > > +#endif > > + > > + /* If there are things to reclaim, try a couple times before gi= ving up. */ > > + if (!freed && remaining > 0 && > > + atomic_inc_return(&ptdev->reclaim.retry_count) < 2) > > + return 0; > > + > > + atomic_set(&ptdev->reclaim.retry_count, 0); > > + > > + if (freed) > > + return freed; > > + > > + /* There's nothing left to reclaim, or the resources are conten= ded. Give up now. */ > > + return SHRINK_STOP; > > +} =20