public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Jonathan Corbet <corbet@lwn.net>,
	Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	kernel@collabora.com, Tvrtko Ursulin <tursulin@ursulin.net>,
	Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
	dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Mihail Atanassov <mihail.atanassov@arm.com>
Subject: Re: [PATCH v9 3/5] drm/panthor: Expose size of driver internal BO's over fdinfo
Date: Fri, 24 Jan 2025 09:48:30 +0100	[thread overview]
Message-ID: <20250124094830.12c17b93@collabora.com> (raw)
In-Reply-To: <20250123225325.3271764-4-adrian.larumbe@collabora.com>

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

  reply	other threads:[~2025-01-24  8:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 22:52 [PATCH v9 0/5] drm/panthor: Display size of internal kernel BOs through fdinfo Adrián Larumbe
2025-01-23 22:52 ` [PATCH v9 1/5] Documentation/gpu: Clarify format of driver-specific fidnfo keys Adrián Larumbe
2025-01-23 22:52 ` [PATCH v9 2/5] drm/file: Add fdinfo helper for printing regions with prefix Adrián Larumbe
2025-01-23 22:53 ` [PATCH v9 3/5] drm/panthor: Expose size of driver internal BO's over fdinfo Adrián Larumbe
2025-01-24  8:48   ` Boris Brezillon [this message]
2025-01-24  9:07     ` Boris Brezillon
2025-01-24 12:06   ` kernel test robot
2025-01-23 22:53 ` [PATCH v9 4/5] Documentation/gpu: Add fdinfo meanings of panthor-*-memory tags Adrián Larumbe
2025-01-23 22:53 ` [PATCH v9 5/5] drm/panthor: Fix race condition when gathering fdinfo group samples Adrián Larumbe
2025-01-24  9:06   ` Boris Brezillon
2025-01-24 16:18   ` 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=20250124094830.12c17b93@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mihail.atanassov@arm.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tursulin@ursulin.net \
    --cc=tvrtko.ursulin@igalia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox