[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250124100737.23dbe0fe@collabora.com>
Date: Fri, 24 Jan 2025 10:07:37 +0100
From: Boris Brezillon <boris.brezillon@...labora.com>
To: Adrián Larumbe <adrian.larumbe@...labora.com>
Cc: David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
<mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, Jonathan
Corbet <corbet@....net>, Steven Price <steven.price@....com>, Liviu Dudau
<liviu.dudau@....com>, kernel@...labora.com, Tvrtko Ursulin
<tursulin@...ulin.net>, Tvrtko Ursulin <tvrtko.ursulin@...lia.com>,
dri-devel@...ts.freedesktop.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, Mihail Atanassov <mihail.atanassov@....com>
Subject: Re: [PATCH v9 3/5] drm/panthor: Expose size of driver internal BO's
over fdinfo
On Fri, 24 Jan 2025 09:48:30 +0100
Boris Brezillon <boris.brezillon@...labora.com> wrote:
> On Thu, 23 Jan 2025 22:53:00 +0000
> Adrián Larumbe <adrian.larumbe@...labora.com> wrote:
>
> > +/**
> > + * panthor_vm_heaps_sizes() - Calculate size of all heap chunks across all
> > + * heaps over all the heap pools in a VM
> > + * @pfile: File.
> > + * @stats: Memory stats to be updated.
> > + *
> > + * Calculate all heap chunk sizes in all heap pools bound to a VM. If the VM
> > + * is active, record the size as active as well.
> > + */
> > +void panthor_vm_heaps_sizes(struct panthor_file *pfile, struct drm_memory_stats *stats)
> > +{
> > + struct panthor_vm *vm;
> > + unsigned long i;
> > +
> > + if (!pfile->vms)
> > + return;
> > +
> > + xa_lock(&pfile->vms->xa);
> > + xa_for_each(&pfile->vms->xa, i, vm) {
> > + size_t size;
> > +
> > + mutex_lock(&vm->heaps.lock);
> > + if (!vm->heaps.pool) {
> > + mutex_unlock(&vm->heaps.lock);
> > + continue;
> > + }
> > + size = panthor_heap_pool_size(vm->heaps.pool);
> > + mutex_unlock(&vm->heaps.lock);
>
> Let's keep the locking scheme simple:
>
> size_t size = 0;
>
> mutex_lock(&vm->heaps.lock);
> if (vm->heaps.pool)
> size = panthor_heap_pool_size(vm->heaps.pool);
> mutex_unlock(&vm->heaps.lock);
>
> stats->resident += size;
> if (vm->as.id >= 0)
> stats->active += size;
With this addressed, you can add
Reviewed-by: Boris Brezillon <boris.brezillon@...labora.com>
>
> > +
> > + stats->resident += size;
> > + if (vm->as.id >= 0)
> > + stats->active += size;
> > + }
> > + xa_unlock(&pfile->vms->xa);
> > +}
> > +
Powered by blists - more mailing lists