From: Karol Wachowski <karol.wachowski@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, jeff.hugo@oss.qualcomm.com,
maciej.falkowski@linux.intel.com, lizhi.hou@amd.com,
Karol Wachowski <karol.wachowski@linux.intel.com>
Subject: [PATCH 2/2] accel/ivpu: Count only resident buffers in memory utilization
Date: Thu, 6 Nov 2025 11:10:52 +0100 [thread overview]
Message-ID: <20251106101052.1050348-3-karol.wachowski@linux.intel.com> (raw)
In-Reply-To: <20251106101052.1050348-1-karol.wachowski@linux.intel.com>
Do not count buffer objects that have no backing pages, including imported
buffers where pages are set by VM faults triggered by userspace or pinned
by other drivers. Instead, return information about actual memory used by
the NPU.
Counting imported buffers results in incorrect calculations when
the same pages are counted multiple times, giving overly high
results.
Fixes: 7bfc9fa99580 ("accel/ivpu: Expose NPU memory utilization info in sysfs")
Signed-off-by: Karol Wachowski <karol.wachowski@linux.intel.com>
---
drivers/accel/ivpu/ivpu_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/ivpu/ivpu_sysfs.c b/drivers/accel/ivpu/ivpu_sysfs.c
index 268ab7744a8b..d250a10caca9 100644
--- a/drivers/accel/ivpu/ivpu_sysfs.c
+++ b/drivers/accel/ivpu/ivpu_sysfs.c
@@ -63,7 +63,8 @@ npu_memory_utilization_show(struct device *dev, struct device_attribute *attr, c
mutex_lock(&vdev->bo_list_lock);
list_for_each_entry(bo, &vdev->bo_list, bo_list_node)
- total_npu_memory += bo->base.base.size;
+ if (ivpu_bo_is_resident(bo))
+ total_npu_memory += ivpu_bo_size(bo);
mutex_unlock(&vdev->bo_list_lock);
return sysfs_emit(buf, "%lld\n", total_npu_memory);
--
2.43.0
next prev parent reply other threads:[~2025-11-06 10:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 10:10 [PATCH 0/2] accel/ivpu: Add memory statistics support Karol Wachowski
2025-11-06 10:10 ` [PATCH 1/2] accel/ivpu: Add fdinfo support for memory statistics Karol Wachowski
2025-11-07 16:12 ` Jeff Hugo
2025-11-08 6:05 ` kernel test robot
2025-11-06 10:10 ` Karol Wachowski [this message]
2025-11-07 16:13 ` [PATCH 2/2] accel/ivpu: Count only resident buffers in memory utilization Jeff Hugo
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=20251106101052.1050348-3-karol.wachowski@linux.intel.com \
--to=karol.wachowski@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=lizhi.hou@amd.com \
--cc=maciej.falkowski@linux.intel.com \
--cc=oded.gabbay@gmail.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