Re: [PATCH V1] accel/amdxdna: Add per-process BO memory usage query support

From: Lizhi Hou

Date: Tue Mar 31 2026 - 12:14:20 EST



On 3/30/26 19:30, Ian Rogers wrote:
On Wed, Mar 25, 2026 at 11:47 AM Lizhi Hou <lizhi.hou@xxxxxxx> wrote:
Applied to drm-misc-next.

On 3/24/26 10:01, Mario Limonciello wrote:

On 3/24/26 11:31, Lizhi Hou wrote:
From: Max Zhen <max.zhen@xxxxxxx>

Add support for querying per-process buffer object (BO) memory
usage through the amdxdna GET_ARRAY UAPI.

Introduce a new query type, DRM_AMDXDNA_BO_USAGE, along with
struct amdxdna_drm_bo_usage to report BO memory usage statistics,
including heap, total, and internal usage.

Track BO memory usage on a per-client basis by maintaining counters
in GEM open/close and heap allocation/free paths. This ensures the
reported statistics reflect the current memory footprint of each
process.

Wire the new query into the GET_ARRAY implementation to expose
the usage information to userspace.

Signed-off-by: Max Zhen <max.zhen@xxxxxxx>
Reviewed-by: Lizhi Hou <lizhi.hou@xxxxxxx>
Signed-off-by: Lizhi Hou <lizhi.hou@xxxxxxx>
I'm assuming you also have userspace side ready for this too right?
If you have a link handy can you please include it when committing.
Sorry for a naive question, would support in procfs be possible?

Do you mean fdinfo? And yes, the fdinfo is in our upstream stack. I will post the patch later.

Lizhi

There's support in perf for displaying DRM usage stat data from there
[1], for example:
```
$ perf list drm-

List of pre-defined events (to be used in -e or -M):


drm:
drm-active-stolen-system0
[Total memory active in one or more engines. Unit: drm_i915]
drm-active-system0
[Total memory active in one or more engines. Unit: drm_i915]
drm-engine-capacity-video
[Engine capacity. Unit: drm_i915]
drm-engine-copy
[Utilization in ns. Unit: drm_i915]
drm-engine-render
[Utilization in ns. Unit: drm_i915]
drm-engine-video
[Utilization in ns. Unit: drm_i915]
drm-engine-video-enhance
[Utilization in ns. Unit: drm_i915]
drm-purgeable-stolen-system0
[Size of resident and purgeable memory buffers. Unit: drm_i915]
drm-purgeable-system0
[Size of resident and purgeable memory buffers. Unit: drm_i915]
drm-resident-stolen-system0
[Size of resident memory buffers. Unit: drm_i915]
drm-resident-system0
[Size of resident memory buffers. Unit: drm_i915]
drm-shared-stolen-system0
[Size of shared memory buffers. Unit: drm_i915]
drm-shared-system0
[Size of shared memory buffers. Unit: drm_i915]
drm-total-stolen-system0
[Size of shared and private memory. Unit: drm_i915]
drm-total-system0
[Size of shared and private memory. Unit: drm_i915]


$ perf stat -e drm-engine-render -a sleep 1

Performance counter stats for 'system wide':

557,542,732,344 ns drm-engine-render

1.001575975 seconds time elapsed
```

Thanks,
Ian

[1] https://lore.kernel.org/lkml/20250403202439.57791-1-irogers@xxxxxxxxxx/