From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
Cc: "Liviu Dudau" <liviu.dudau@arm.com>,
"Adrián Larumbe" <adrian.larumbe@collabora.com>,
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 v4 5/9] drm/panthor: Part ways with drm_gem_shmem_object
Date: Fri, 6 Mar 2026 13:15:11 +0100 [thread overview]
Message-ID: <20260306131511.65cd2c73@fedora> (raw)
In-Reply-To: <347054fe-8a71-470e-9e1f-7d9f6d328ed5@arm.com>
On Fri, 6 Mar 2026 11:58:09 +0000
Steven Price <steven.price@arm.com> wrote:
> On 05/03/2026 12:43, Boris Brezillon wrote:
> > While drm_gem_shmem_object does most of the job we need it to do, the
> > way sub-resources (pages, sgt, vmap) are handled and their lifetimes
> > gets in the way of BO reclaim. There has been attempts to address
> > that [1], but in the meantime, new gem_shmem users were introduced
> > (accel drivers), and some of them manually free some of these resources.
> > This makes things harder to control/sanitize/validate.
> >
> > Thomas Zimmerman is not a huge fan of enforcing lifetimes of sub-resources
> > and forcing gem_shmem users to go through new gem_shmem helpers when they
> > need manual control of some sort, and I believe this is a dead end if
> > we don't force users to follow some stricter rules through carefully
> > designed helpers, because there will always be one user doing crazy things
> > with gem_shmem_object internals, which ends up tripping out the common
> > helpers when they are called.
> >
> > The consensus we reached was that we would be better off forking
> > gem_shmem in panthor. So here we are, parting ways with gem_shmem. The
> > current transition tries to minimize the changes, but there are still
> > some aspects that are different, the main one being that we no longer
> > have a pages_use_count, and pages stays around until the GEM object is
> > destroyed (or when evicted once we've added a shrinker). The sgt also
> > no longer retains pages. This is losely based on how msm does things by
> > the way.
> >
> > If there's any interest in sharing code (probably with msm, since the
> > panthor shrinker is going to be losely based on the msm implementation),
> > we can always change gears and do that once we have everything
> > working/merged.
> >
> > [1]https://patchwork.kernel.org/project/dri-devel/patch/20240105184624.508603-1-dmitry.osipenko@collabora.com/
> >
> > v2:
> > - Fix refcounting
> > - Add a _locked suffix to a bunch of functions expecting the resv lock
> > to be held
> > - Take the lock before releasing resources in panthor_gem_free_object()
> >
> > v3:
> > - Use ERR_CAST() to fix an ERR-ptr deref
> > - Add missing resv_[un]lock() around a panthor_gem_backing_unpin_locked()
> > call
> >
> > v4:
> > - Fix an error path in panthor_gem_vmap_get_locked()
> > - Don't leave bo->base.pages with an ERR_PTR()
> > - Make panthor_gem_{pin,unpin}[_locked]() more consistent
> > - Don't fail in panthor_gem_dev_map_get_sgt_locked() if the pages are not
> > allocated
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> > drivers/gpu/drm/panthor/Kconfig | 1 -
> > drivers/gpu/drm/panthor/panthor_drv.c | 7 +-
> > drivers/gpu/drm/panthor/panthor_fw.c | 16 +-
> > drivers/gpu/drm/panthor/panthor_gem.c | 700 ++++++++++++++++++++----
> > drivers/gpu/drm/panthor/panthor_gem.h | 62 ++-
> > drivers/gpu/drm/panthor/panthor_mmu.c | 48 +-
> > drivers/gpu/drm/panthor/panthor_sched.c | 9 +-
> > 7 files changed, 669 insertions(+), 174 deletions(-)
> >
>
> One minor issue below (and of course the kernel test robot's report).
>
> [...]
>
> > @@ -646,7 +1108,7 @@ static void panthor_gem_debugfs_bo_print(struct panthor_gem_object *bo,
> > struct seq_file *m,
> > struct gem_size_totals *totals)
> > {
> > - unsigned int refcount = kref_read(&bo->base.base.refcount);
> > + unsigned int refcount = kref_read(&bo->base.refcount);
> > char creator_info[32] = {};
> > size_t resident_size;
> > u32 gem_usage_flags = bo->debugfs.flags;
> > @@ -656,21 +1118,21 @@ static void panthor_gem_debugfs_bo_print(struct panthor_gem_object *bo,
> > if (!refcount)
> > return;
> >
> > - resident_size = bo->base.pages ? bo->base.base.size : 0;
> > + resident_size = bo->backing.pages ? bo->base.size : 0;
> >
> > snprintf(creator_info, sizeof(creator_info),
> > "%s/%d", bo->debugfs.creator.process_name, bo->debugfs.creator.tgid);
> > seq_printf(m, "%-32s%-16d%-16d%-16zd%-16zd0x%-16lx",
> > creator_info,
> > - bo->base.base.name,
> > + bo->base.name,
> > refcount,
> > - bo->base.base.size,
> > + bo->base.size,
> > resident_size,
> > - drm_vma_node_start(&bo->base.base.vma_node));
> > + drm_vma_node_start(&bo->base.vma_node));
> >
> > - if (drm_gem_is_imported(&bo->base.base))
> > + if (drm_gem_is_imported(&bo->base))
> > gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_IMPORTED;
> > - if (bo->base.base.dma_buf)
> > + if (bo->base.dma_buf)
> > gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_EXPORTED;
> >
> > seq_printf(m, "0x%-8x 0x%-10x", gem_state_flags, gem_usage_flags);
> > @@ -679,10 +1141,8 @@ static void panthor_gem_debugfs_bo_print(struct panthor_gem_object *bo,
> > seq_printf(m, "%s\n", bo->label.str ? : "");
> > }
> >
> > - totals->size += bo->base.base.size;
> > + totals->size += bo->base.size;
> > totals->resident += resident_size;
> > - if (bo->base.madv > 0)
> > - totals->reclaimable += resident_size;
>
> You've dropped the code for calculating totals->reclaimable - but the
> code for printing this out is still there. So it'll print out "Total
> reclaimable: 0" always.
I'm mean, it's always been zero anyway, because we never added MADVISE
support, so I'm not too sure it matters in this patch. We should
probably hook that up again in the commit adding the shrinker, based on
the object state.
>
> Thanks,
> Steve
>
next prev parent reply other threads:[~2026-03-06 12:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 12:43 [PATCH v4 0/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 1/9] drm/gem: Consider GEM object reclaimable if shrinking fails Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 2/9] drm/panthor: Move panthor_gems_debugfs_init() to panthor_gem.c Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 3/9] drm/panthor: Group panthor_kernel_bo_xxx() helpers Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 4/9] drm/panthor: Don't call drm_gpuvm_bo_extobj_add() if the object is private Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 5/9] drm/panthor: Part ways with drm_gem_shmem_object Boris Brezillon
2026-03-06 8:01 ` kernel test robot
2026-03-06 11:58 ` Steven Price
2026-03-06 12:15 ` Boris Brezillon [this message]
2026-03-06 12:17 ` Steven Price
2026-03-05 12:43 ` [PATCH v4 6/9] drm/panthor: Lazily allocate pages on mmap() Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 7/9] drm/panthor: Split panthor_vm_prepare_map_op_ctx() to prepare for reclaim Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 8/9] drm/panthor: Track the number of mmap on a BO Boris Brezillon
2026-03-05 12:43 ` [PATCH v4 9/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-03-06 15:17 ` Steven Price
2026-03-09 10:44 ` Boris Brezillon
2026-03-06 11:58 ` [PATCH v4 0/9] " Steven Price
2026-03-06 12:30 ` Boris Brezillon
2026-03-06 15:13 ` Steven Price
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=20260306131511.65cd2c73@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.