public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Steven Price" <steven.price@arm.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH 1/4] drm/panthor: Add freed_sz parameter to reclaim_priv_bos
Date: Wed, 06 May 2026 17:19:59 +0200	[thread overview]
Message-ID: <uhheTk9bTneBzwQGdN_KPA@collabora.com> (raw)
In-Reply-To: <ed1b0be1-cf6e-4318-b040-12d315eae3f0@arm.com>

On Wednesday, 6 May 2026 17:06:57 Central European Summer Time Steven Price wrote:
> On 06/05/2026 11:45, Nicolas Frattaroli wrote:
> > panthor_mmu_reclaim_priv_bos returns the number of freed pages. However,
> > how many bytes of freed memory this translates to can't generally be
> > deduced from the number of pages, as the page size is a per-VM property.
> > 
> > It may be useful to know the exact number of bytes that have been freed
> 
> The "useful" aspect seems to just be a drm_dbg() message from what I can
> see with this series?

Correct.

> Am I missing something or is it not actually that useful?

I wanted to know how much memory I'm actually reclaiming without
making any assumptions about page sizes, and figured the change is
innocent enough. If it's deemed too pointless, then I'll just drop
the size in bytes from the debug message.

Kind regards,
Nicolas Frattaroli

> 
> Thanks,
> Steve
> 
> > for observability and debugging purposes. To that end, add a new
> > parameter "freed_sz", which is a pointer to a size_t where this
> > information will be stored. It may be NULL, in which case the
> > information isn't stored at all.
> > 
> > Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> > ---
> >  drivers/gpu/drm/panthor/panthor_gem.c |  3 ++-
> >  drivers/gpu/drm/panthor/panthor_mmu.c | 12 ++++++++++--
> >  drivers/gpu/drm/panthor/panthor_mmu.h |  1 +
> >  3 files changed, 13 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> > index 13295d7a593d..80e82238f3c5 100644
> > --- a/drivers/gpu/drm/panthor/panthor_gem.c
> > +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> > @@ -1511,7 +1511,8 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc)
> >  		goto out;
> >  
> >  	freed += panthor_mmu_reclaim_priv_bos(ptdev, sc->nr_to_scan - freed,
> > -					      &remaining, panthor_gem_try_evict);
> > +					      &remaining, NULL,
> > +					      panthor_gem_try_evict);
> >  	if (freed >= sc->nr_to_scan)
> >  		goto out;
> >  
> > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> > index a7ee14986849..b81388b35a58 100644
> > --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> > @@ -3127,13 +3127,18 @@ int panthor_vm_prepare_mapped_bos_resvs(struct drm_exec *exec, struct panthor_vm
> >  unsigned long
> >  panthor_mmu_reclaim_priv_bos(struct panthor_device *ptdev,
> >  			     unsigned int nr_to_scan, unsigned long *remaining,
> > +			     size_t *freed_sz,
> >  			     bool (*shrink)(struct drm_gem_object *,
> >  					    struct ww_acquire_ctx *))
> >  {
> > +	unsigned long newly_freed;
> >  	unsigned long freed = 0;
> >  	LIST_HEAD(remaining_vms);
> >  	LIST_HEAD(vms);
> >  
> > +	if (freed_sz)
> > +		*freed_sz = 0;
> > +
> >  	mutex_lock(&ptdev->reclaim.lock);
> >  	list_splice_init(&ptdev->reclaim.vms, &vms);
> >  
> > @@ -3152,8 +3157,11 @@ panthor_mmu_reclaim_priv_bos(struct panthor_device *ptdev,
> >  
> >  		mutex_unlock(&ptdev->reclaim.lock);
> >  
> > -		freed += drm_gem_lru_scan(&vm->reclaim.lru, nr_to_scan - freed,
> > -					  remaining, shrink, NULL);
> > +		newly_freed = drm_gem_lru_scan(&vm->reclaim.lru, nr_to_scan - freed,
> > +					       remaining, shrink, NULL);
> > +		if (freed_sz)
> > +			*freed_sz += panthor_vm_page_size(vm) * newly_freed;
> > +		freed += newly_freed;
> >  
> >  		mutex_lock(&ptdev->reclaim.lock);
> >  
> > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.h b/drivers/gpu/drm/panthor/panthor_mmu.h
> > index 3522fbbce369..12b18b5f90e1 100644
> > --- a/drivers/gpu/drm/panthor/panthor_mmu.h
> > +++ b/drivers/gpu/drm/panthor/panthor_mmu.h
> > @@ -52,6 +52,7 @@ int panthor_vm_evict_bo_mappings_locked(struct panthor_gem_object *bo);
> >  unsigned long
> >  panthor_mmu_reclaim_priv_bos(struct panthor_device *ptdev,
> >  			     unsigned int nr_to_scan, unsigned long *remaining,
> > +			     size_t *freed_sz,
> >  			     bool (*shrink)(struct drm_gem_object *,
> >  					    struct ww_acquire_ctx *));
> >  int panthor_vm_prepare_mapped_bos_resvs(struct drm_exec *exec,
> > 
> 
> 





  reply	other threads:[~2026-05-06 15:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 10:45 [PATCH 0/4] Let userspace explicitly trigger memory reclaims Nicolas Frattaroli
2026-05-06 10:45 ` [PATCH 1/4] drm/panthor: Add freed_sz parameter to reclaim_priv_bos Nicolas Frattaroli
2026-05-06 15:06   ` Steven Price
2026-05-06 15:19     ` Nicolas Frattaroli [this message]
2026-05-06 10:45 ` [PATCH 2/4] MAINTAINERS: Add sysfs ABI docs to list of panthor files Nicolas Frattaroli
2026-05-06 10:45 ` [PATCH 3/4] drm/panthor: Add explicit memory reclaim sysfs knob Nicolas Frattaroli
2026-05-06 10:45 ` [PATCH 4/4] drm/panthor: Add explicit memory claim " Nicolas Frattaroli
2026-05-06 15:06 ` [PATCH 0/4] Let userspace explicitly trigger memory reclaims Steven Price
2026-05-06 15:43   ` Nicolas Frattaroli
2026-05-06 15:55     ` 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=uhheTk9bTneBzwQGdN_KPA@collabora.com \
    --to=nicolas.frattaroli@collabora.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=sumit.semwal@linaro.org \
    --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