Re: [PATCH v9 3/5] drm/panthor: Expose size of driver internal BO's over fdinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 24 Jan 2025 09:48:30 +0100
Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote:

> On Thu, 23 Jan 2025 22:53:00 +0000
> Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>

> 		
> > +
> > +		stats->resident += size;
> > +		if (vm->as.id >= 0)
> > +			stats->active += size;
> > +	}
> > +	xa_unlock(&pfile->vms->xa);
> > +}
> > +  





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux