From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
"Steven Price" <steven.price@arm.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Akash Goel" <akash.goel@arm.com>,
"Rob Clark" <robin.clark@oss.qualcomm.com>,
"Sean Paul" <sean@poorly.run>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Akhil P Oommen" <akhilpo@oss.qualcomm.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Chris Diamand" <chris.diamand@arm.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Chia-I Wu" <olvaffe@gmail.com>,
kernel@collabora.com
Subject: Re: [PATCH v7 00/10] drm/panthor: Add a GEM shrinker
Date: Fri, 3 Apr 2026 13:54:04 +0200 [thread overview]
Message-ID: <20260403135404.431fe625@fedora> (raw)
In-Reply-To: <20260401134854.2275433-1-boris.brezillon@collabora.com>
On Wed, 1 Apr 2026 15:48:44 +0200
Boris Brezillon <boris.brezillon@collabora.com> wrote:
> Hello,
>
> This is an attempt at adding a GEM shrinker to panthor so the system
> can finally reclaim GPU memory.
>
> This implementation is losely based on the MSM shrinker (which is why
> I added the MSM maintainers in Cc), and it's relying on the drm_gpuvm
> eviction/validation infrastructure.
>
> I've only done very basic IGT-based [1] and chromium-based (opening
> a lot of tabs on Aquarium until the system starts reclaiming+swapping
> out GPU buffers) testing, but I'm posting this early so I can get
> preliminary feedback on the implementation. If someone knows about
> better tools/ways to test the shrinker, please let me know.
>
> A few words about some design/implementation choices:
> - No MADVISE support because I want to see if we can live with just
> transparent reclaim
> - We considered basing this implementation on the generic shrinker work
> started by Dmitry [2], but
> 1. with the activeness/idleness tracking happening at the VM
> granularity, having per-BO LRUs would caused a lot of
> list_move()s that are not really needed (the VM as a whole
> become active/idle, we can track individual BOs)
> 2. Thomas Zimmermann recently suggested that we should have our
> own GEM implementation instead of trying to add this extra reclaim
> complexity to gem-shmem. There are some plans to create a
> gem-uma (Unified Memory Architecture) lib that would do more
> than gem-shmem but in a way that doesn't force all its users
> to pay the overhead (size overhead of the gem object, mostly)
> for features they don't use. Patch "Part ways with
> drm_gem_shmem_object" is showing what this component-based lib
> API could look like if it were to be extracted
> - At the moment we only support swapout, but we could add an
> extra flag to specify when buffer content doesn't need to be
> preserved to avoid the swapout/swapin dance. First candidate for
> this DISCARD_ON_RECLAIM flag would probably be the tiler heap chunks.
> - Reclaim uses _try_lock() all the way because of the various lock order
> inversions between the reclaim path and submission paths. That means
> we don't try very hard to reclaim hot GPU buffers, but the locking is
> such a mess that I don't really see a better option to be honest.
>
>
> Changes in v2:
> - No fundamental changes in this v2, since the feedback I got were more
> focused on bugs than the overall approach. Check the changelog in each
> patch for more details.
>
> Changes in v3:
> - Mostly fixes (see the changelog in each patch)
>
> Changes in v4:
> - Only fixes (see the changelog in each patch)
>
> Changes in v5:
> - Only fixes (see the changelog in each patch)
>
> Changes in v6:
> - Fix huge fault handling and various other things reported by Adrian
> and the review bot (see the changelog in each patch for more)
>
> Changes in v7:
> - Fix a deadlock reported by lockdep
> - Add a commit to remove an unused field
>
> Regards,
>
> Boris
>
> [1]https://gitlab.freedesktop.org/bbrezillon/igt-gpu-tools/-/commit/fc76934a5579767d2aabe787d40e38a17c3f4ea4
> [2]https://lkml.org/lkml/2024/1/5/665
>
> Akash Goel (1):
> drm/panthor: Add a GEM shrinker
>
> Boris Brezillon (9):
> drm/gem: Consider GEM object reclaimable if shrinking fails
> drm/panthor: Remove unused panthor_vm_op_ctx::map::new_vma field
> drm/panthor: Move panthor_gems_debugfs_init() to panthor_gem.c
> drm/panthor: Group panthor_kernel_bo_xxx() helpers
> drm/panthor: Don't call drm_gpuvm_bo_extobj_add() if the object is
> private
> drm/panthor: Part ways with drm_gem_shmem_object
> drm/panthor: Lazily allocate pages on mmap()
> drm/panthor: Split panthor_vm_prepare_map_op_ctx() to prepare for
> reclaim
> drm/panthor: Track the number of mmap on a BO
Queued to drm-misc-next.
>
> drivers/gpu/drm/drm_gem.c | 10 +
> drivers/gpu/drm/panthor/Kconfig | 1 -
> drivers/gpu/drm/panthor/panthor_device.c | 11 +-
> drivers/gpu/drm/panthor/panthor_device.h | 73 ++
> drivers/gpu/drm/panthor/panthor_drv.c | 33 +-
> drivers/gpu/drm/panthor/panthor_fw.c | 16 +-
> drivers/gpu/drm/panthor/panthor_gem.c | 1453 ++++++++++++++++++----
> drivers/gpu/drm/panthor/panthor_gem.h | 136 +-
> drivers/gpu/drm/panthor/panthor_mmu.c | 512 ++++++--
> drivers/gpu/drm/panthor/panthor_mmu.h | 8 +
> drivers/gpu/drm/panthor/panthor_sched.c | 9 +-
> 11 files changed, 1923 insertions(+), 339 deletions(-)
>
prev parent reply other threads:[~2026-04-03 11:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 13:48 [PATCH v7 00/10] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 01/10] drm/gem: Consider GEM object reclaimable if shrinking fails Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 02/10] drm/panthor: Remove unused panthor_vm_op_ctx::map::new_vma field Boris Brezillon
2026-04-02 14:31 ` Liviu Dudau
2026-04-01 13:48 ` [PATCH v7 03/10] drm/panthor: Move panthor_gems_debugfs_init() to panthor_gem.c Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 04/10] drm/panthor: Group panthor_kernel_bo_xxx() helpers Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 05/10] drm/panthor: Don't call drm_gpuvm_bo_extobj_add() if the object is private Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 06/10] drm/panthor: Part ways with drm_gem_shmem_object Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 07/10] drm/panthor: Lazily allocate pages on mmap() Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 08/10] drm/panthor: Split panthor_vm_prepare_map_op_ctx() to prepare for reclaim Boris Brezillon
2026-04-01 13:48 ` [PATCH v7 09/10] drm/panthor: Track the number of mmap on a BO Boris Brezillon
2026-04-02 14:33 ` Liviu Dudau
2026-04-01 13:48 ` [PATCH v7 10/10] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-04-03 11:54 ` Boris Brezillon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260403135404.431fe625@fedora \
--to=boris.brezillon@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=akash.goel@arm.com \
--cc=akhilpo@oss.qualcomm.com \
--cc=aliceryhl@google.com \
--cc=chris.diamand@arm.com \
--cc=dakr@kernel.org \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=konradybcio@kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox