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 8C4D0D44C51 for ; Thu, 15 Jan 2026 14:36:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C635210E0AD; Thu, 15 Jan 2026 14:36:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="namPdomt"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E17610E0AD for ; Thu, 15 Jan 2026 14:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1768487782; bh=Ct6qKhbCJUEkHn3gx+fIG8nx6b/6TrJ9/3Kzzl8TGmk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=namPdomtR/87cpIuSuvhjhwU4QynDSbXHiAJOHrmrewiBY5U0Bo4bTYOshlK1Fk0o TD5SHTpQ6qY6srDwN9a1PLYLTMLSIwExGGD+RcmV3r8XwEAW1Wo2RXRLTSAaewyMoo RA3Hj4RX7bOKvCaowW1B9e5R1HBxNNuYOfveJssePU5SCgJliH1nxGHYtR73pBWBdw KKKmsY2C2ZoVBdjNrD2KwjISAdjYCxg9Os/ukmrgPFj3PAW4ZgPum36bI/a8+pH8iA wqIhpvUgR9OqoMH0gjjhJN/0tSEd5MVq7O4oEt2CGB64UXl68giFp63pAICreTNS1Y VrSI4dpEBxV3w== 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 14F1E17E10F8; Thu, 15 Jan 2026 15:36:22 +0100 (CET) Date: Thu, 15 Jan 2026 15:36:17 +0100 From: Boris Brezillon To: Akash Goel Cc: Steven Price , Liviu Dudau , =?UTF-8?B?QWRyacOhbg==?= 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 , Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , Alice Ryhl , kernel@collabora.com, nd@arm.com Subject: Re: [PATCH v1 9/9] drm/panthor: Add a GEM shrinker Message-ID: <20260115153617.6f6e72cc@fedora> In-Reply-To: References: <20260109130801.1239558-1-boris.brezillon@collabora.com> <20260109130801.1239558-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=US-ASCII 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 Thu, 15 Jan 2026 13:56:42 +0000 Akash Goel wrote: > > +static unsigned long > > +panthor_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) > > +{ > > + struct panthor_device *ptdev = shrinker->private_data; > > + unsigned long count; > > + > > + /* We currently don't have a flag to tell when the content of a > > + * BO can be discarded. > > + */ > > + if (!can_swap()) > > + return 0; > > + > > + count = ptdev->reclaim.unused.count; > > + count += ptdev->reclaim.mmapped.count; > > + > > + if (can_block(sc)) > > + count += ptdev->reclaim.gpu_mapped_count; > > + > > Should we do like this > > return count ? count : SHRINK_EMPTY; > > > Other drivers are also doing the same > > https://elixir.bootlin.com/linux/v6.18.4/source/drivers/gpu/drm/xe/xe_shrinker.c#L156 > > > https://elixir.bootlin.com/linux/v6.18.4/source/drivers/gpu/drm/ttm/ttm_pool.c#L1160 > > https://elixir.bootlin.com/linux/v6.18.4/source/mm/vmalloc.c#L5245 > > It might matter if CONFIG_MEMCG is set. Absolutely. I'll fix that in v2. > > > + return count; > > +} > > /** > > @@ -678,6 +689,16 @@ int panthor_vm_active(struct panthor_vm *vm) > > if (refcount_inc_not_zero(&vm->as.active_cnt)) > > goto out_dev_exit; > > > > + /* As soon as active is called, we place the VM as the end of the VM LRU. > > > Please replace 'as the end' with 'at the end'. Will do.