From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>,
igt-dev@lists.freedesktop.org
Cc: siqueira@igalia.com, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
"Christian Koenig" <christian.koenig@amd.com>,
maarten.lankhorst@linux.intel.com,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Janusz Krzysztofik" <janusz.krzysztofik@linux.intel.com>,
"Vitaly Prosyak" <vitaly.prosyak@amd.com>,
"Natalie Vock" <natalie.vock@gmx.de>,
kernel-dev@igalia.com
Subject: Re: [PATCH i-g-t v6 5/9] lib/amdgpu: add amdgpu_cgroup_region_name
Date: Fri, 4 Sep 2026 11:00:49 +0100 [thread overview]
Message-ID: <8bc27494-ca97-4e21-9710-c9f88b169a6c@igalia.com> (raw)
In-Reply-To: <20260903-dmem_max-v6-5-61dc62970fae@igalia.com>
On 03/09/2026 23:00, Thadeu Lima de Souza Cascardo wrote:
> The amdgpu dmem region name uses its PCI address, just like the one from
> Xe, but there is only a single VRAM region.
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> ---
> lib/amdgpu/amd_memory.c | 25 +++++++++++++++++++++++++
> lib/amdgpu/amd_memory.h | 2 ++
> 2 files changed, 27 insertions(+)
>
> diff --git a/lib/amdgpu/amd_memory.c b/lib/amdgpu/amd_memory.c
> index 12fe23c65ab2..2da4a8a4baee 100644
> --- a/lib/amdgpu/amd_memory.c
> +++ b/lib/amdgpu/amd_memory.c
> @@ -30,9 +30,11 @@
> #include <amdgpu_drm.h>
> #include <stdio.h>
> #include <string.h>
> +#include <limits.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <inttypes.h>
> +#include "igt_device.h"
>
> /**
> *
> @@ -679,6 +681,29 @@ bool virtual_free_memory(void *address, unsigned int size)
> }
> }
>
> +/**
> + * amdgpu_cgroup_region_name() - Build the dmem cgroup region name for an amdgpu.
> + * @fd: amdgpu device fd.
> + *
> + * Constructs the full dmem cgroup region path for VRAM on the device
> + * identified by @fd. The returned string has the form
> + * ``drm/<pci-slot>/vram`` (e.g. ``drm/0000:03:00.0/vram``), matching
> + * the name registered by the kernel driver via drmm_cgroup_register_region().
> + *
> + * Return: A newly allocated string that the caller must free(), or %NULL if
> + * @region is not tracked by the dmem cgroup controller.
> + */
> +char *amdgpu_cgroup_region_name(int fd)
> +{
> + char pci_slot[NAME_MAX];
> + char *name;
> +
> + igt_device_get_pci_slot_name(fd, pci_slot);
> +
> + igt_assert(asprintf(&name, "drm/%s/vram", pci_slot) > 0);
> + return name;
> +}
> +
> /**
> * Wait for specific value in memory with timeout
> */
> diff --git a/lib/amdgpu/amd_memory.h b/lib/amdgpu/amd_memory.h
> index e26c85bc4b0a..de169e580c1b 100644
> --- a/lib/amdgpu/amd_memory.h
> +++ b/lib/amdgpu/amd_memory.h
> @@ -105,6 +105,8 @@ void
> bool
> virtual_free_memory(void *address, unsigned int size);
>
> +char *amdgpu_cgroup_region_name(int fd);
> +
> bool
> wait_on_value(unsigned int *ptr, unsigned int expected);
> #endif
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Regards,
Tvrtko
next prev parent reply other threads:[~2026-09-04 10:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 22:00 [PATCH i-g-t v6 0/9] add cgroup_dmem test Thadeu Lima de Souza Cascardo
2026-09-03 22:00 ` [PATCH i-g-t v6 1/9] lib/igt_cgroup: add cgroup v2 and dmem controller helpers Thadeu Lima de Souza Cascardo
2026-09-03 22:00 ` [PATCH i-g-t v6 2/9] tests/cgroup_dmem: add dmem cgroup controller test Thadeu Lima de Souza Cascardo
2026-09-03 22:00 ` [PATCH i-g-t v6 3/9] lib/xe: add xe_cgroup_region_name() helper Thadeu Lima de Souza Cascardo
2026-09-03 22:00 ` [PATCH i-g-t v6 4/9] lib/xe: Introduce dmem driver and implement Xe support Thadeu Lima de Souza Cascardo
2026-09-04 10:02 ` Tvrtko Ursulin
2026-09-03 22:00 ` [PATCH i-g-t v6 5/9] lib/amdgpu: add amdgpu_cgroup_region_name Thadeu Lima de Souza Cascardo
2026-09-04 10:00 ` Tvrtko Ursulin [this message]
2026-09-03 22:00 ` [PATCH i-g-t v6 6/9] lib/amdgpu: add amdgpu support to igt_dmem_driver Thadeu Lima de Souza Cascardo
2026-09-04 10:11 ` Tvrtko Ursulin
2026-09-03 22:00 ` [PATCH i-g-t v6 7/9] tests/cgroup_dmem: add test for dmem.current Thadeu Lima de Souza Cascardo
2026-09-04 12:40 ` Tvrtko Ursulin
2026-09-03 22:00 ` [PATCH i-g-t v6 8/9] tests/cgroup_dmem: add dmem cgroup eviction test Thadeu Lima de Souza Cascardo
2026-09-04 14:48 ` Tvrtko Ursulin
2026-09-03 22:00 ` [PATCH i-g-t v6 9/9] tests/cgroup_dmem: add write_eviction_nonblock subtest Thadeu Lima de Souza Cascardo
2026-09-04 14:51 ` Tvrtko Ursulin
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=8bc27494-ca97-4e21-9710-c9f88b169a6c@igalia.com \
--to=tvrtko.ursulin@igalia.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=cascardo@igalia.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=kernel-dev@igalia.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=natalie.vock@gmx.de \
--cc=siqueira@igalia.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=vitaly.prosyak@amd.com \
/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