From: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
To: Lizhi Hou <lizhi.hou@amd.com>,
Maciej Falkowski <maciej.falkowski@linux.intel.com>,
dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com
Subject: Re: [PATCH 04/14] accel/ivpu: Expose NPU memory utilization info in sysfs
Date: Thu, 9 Jan 2025 09:19:59 +0100 [thread overview]
Message-ID: <cc01ee0e-d258-46b4-918c-1490de783fe1@linux.intel.com> (raw)
In-Reply-To: <487e9cb5-d867-f608-1b0a-d53df5c681e0@amd.com>
Hi,
On 1/8/2025 8:53 PM, Lizhi Hou wrote:
>
> On 1/7/25 09:32, Maciej Falkowski wrote:
>> Expose NPU memory utilization info in sysfs in bytes
>> to show total memory used by NPU (FW + runtime).
>>
>> Signed-off-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
>> ---
>> drivers/accel/ivpu/ivpu_sysfs.c | 30 +++++++++++++++++++++++++++++-
>> 1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/accel/ivpu/ivpu_sysfs.c b/drivers/accel/ivpu/ivpu_sysfs.c
>> index 8a616791c32f..97102feaf8dd 100644
>> --- a/drivers/accel/ivpu/ivpu_sysfs.c
>> +++ b/drivers/accel/ivpu/ivpu_sysfs.c
>> @@ -7,11 +7,14 @@
>> #include <linux/err.h>
>> #include "ivpu_drv.h"
>> +#include "ivpu_gem.h"
>> #include "ivpu_fw.h"
>> #include "ivpu_hw.h"
>> #include "ivpu_sysfs.h"
>> -/*
>> +/**
>> + * DOC: npu_busy_time_us
>> + *
>> * npu_busy_time_us is the time that the device spent executing jobs.
>> * The time is counted when and only when there are jobs submitted to firmware.
>> *
>> @@ -42,6 +45,30 @@ npu_busy_time_us_show(struct device *dev, struct device_attribute *attr, char *b
>> static DEVICE_ATTR_RO(npu_busy_time_us);
>> +/**
>> + * DOC: npu_memory_utilization
>> + *
>> + * The npu_memory_utilization is used to report in bytes a current NPU memory utilization.
>> + *
>> + */
>> +static ssize_t
>> +npu_memory_utilization_show(struct device *dev, struct device_attribute *attr, char *buf)
>> +{
>> + struct drm_device *drm = dev_get_drvdata(dev);
>> + struct ivpu_device *vdev = to_ivpu_device(drm);
>> + struct ivpu_bo *bo;
>> + u64 total_npu_memory = 0;
>> +
>> + mutex_lock(&vdev->bo_list_lock);
>> + list_for_each_entry(bo, &vdev->bo_list, bo_list_node)
>> + total_npu_memory += bo->base.base.size;
>> + mutex_unlock(&vdev->bo_list_lock);
>> +
>> + return sysfs_emit(buf, "%lld\n", total_npu_memory);
>> +}
>> +
>> +static DEVICE_ATTR_RO(npu_memory_utilization);
>> +
>
> Instead of adding sysfs, maybe implementing show_fdinfo callback and call drm_show_memory_stats()?
show_fdinfo cannot be used for global device stats. We are considering adding per context stats using show_fdinfo but for the moment total device memory usage is our priority.
Regards,
Jacek
next prev parent reply other threads:[~2025-01-09 8:20 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 17:32 [PATCH 00/14] accel/ivpu: Changes for 6.14 Maciej Falkowski
2025-01-07 17:32 ` [PATCH 01/14] accel/ivpu: Separate DB ID and CMDQ ID allocations from CMDQ allocation Maciej Falkowski
2025-01-09 8:22 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 02/14] accel/ivpu: Add API for command queue create/destroy/submit Maciej Falkowski
2025-01-09 8:22 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 03/14] accel/ivpu: Abort all jobs after command queue unregister Maciej Falkowski
2025-01-09 8:23 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 04/14] accel/ivpu: Expose NPU memory utilization info in sysfs Maciej Falkowski
2025-01-08 19:53 ` Lizhi Hou
2025-01-09 8:19 ` Jacek Lawrynowicz [this message]
2025-01-09 8:24 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 05/14] accel/ivpu: Use workqueue for IRQ handling Maciej Falkowski
2025-01-09 8:26 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 06/14] accel/ivpu: Dump only first MMU fault from single context Maciej Falkowski
2025-01-09 8:26 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 07/14] accel/ivpu: Move parts of MMU event IRQ handling to thread handler Maciej Falkowski
2025-01-09 8:27 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 08/14] accel/ivpu: Fix missing MMU events from reserved SSID Maciej Falkowski
2025-01-09 8:27 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 09/14] accel/ivpu: Set command queue management capability based on HWS Maciej Falkowski
2025-01-09 8:28 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 10/14] accel/ivpu: Fix locking order in ivpu_cmdq_destroy_ioctl Maciej Falkowski
2025-01-09 8:28 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 11/14] accel/ivpu: Fix locking order in ivpu_job_submit Maciej Falkowski
2025-01-09 8:28 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 12/14] accel/ivpu: Add handling of VPU_JSM_STATUS_MVNCI_CONTEXT_VIOLATION_HW Maciej Falkowski
2025-01-09 8:29 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 13/14] accel/ivpu: Add platform detection for presilicon Maciej Falkowski
2025-01-09 8:29 ` Jacek Lawrynowicz
2025-01-07 17:32 ` [PATCH 14/14] accel/ivpu: Enable HWS by default on all platforms Maciej Falkowski
2025-01-08 18:19 ` [PATCH 00/14] accel/ivpu: Changes for 6.14 Simona Vetter
2025-01-09 8:14 ` Jacek Lawrynowicz
2025-01-09 8:43 ` Jacek Lawrynowicz
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=cc01ee0e-d258-46b4-918c-1490de783fe1@linux.intel.com \
--to=jacek.lawrynowicz@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lizhi.hou@amd.com \
--cc=maciej.falkowski@linux.intel.com \
--cc=oded.gabbay@gmail.com \
--cc=quic_jhugo@quicinc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.