[PATCH v9 3/5] drm/panthor: Expose size of driver internal BO's over fdinfo
Boris Brezillon
boris.brezillon at collabora.com
Fri Jan 24 08:48:30 UTC 2025
On Thu, 23 Jan 2025 22:53:00 +0000
Adrián Larumbe <adrian.larumbe at collabora.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;
> +
> + stats->resident += size;
> + if (vm->as.id >= 0)
> + stats->active += size;
> + }
> + xa_unlock(&pfile->vms->xa);
> +}
> +
More information about the dri-devel
mailing list