drm/amd/amdkfd: Surface files in Sysfs to allow users to get number of compute units that are in use.
Subsystems (3)
PATCH 4/4 drm/amd/amdkfd: Surface files in Sysfs to allow users to get number of compute units that are in use.
[Why]
Allow user to know how many compute units (CU) are in use at any given moment.
[How]
Surface files in Sysfs that allow user to determine the number of compute units that are in use for a given process. One Sysfs file is used per device.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 25 +++++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 71 +++++++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +25 -0
@@ -705,6 +705,31 @@ struct kfd_process_device {struct kobject *kobj_stats;unsigned int doorbell_index; + +/* +* @cu_occupancy: Reports occupancy of Compute Units (CU) of a process +* that is associated with device encoded by "this" struct instance. The +* value reflects CU usage by all of the waves launched by this process +* on this device. A very important property of occupancy parameter is +* that its value is a snapshot of current use. +* +* Following is to be noted regarding how this parameter is reported: +* +* The number of waves that a CU can launch is limited by couple of +* parameters. These are encoded by struct amdgpu_cu_info instance +* that is part of every device definition. For GFX9 devices this +* translates to 40 waves (simd_per_cu * max_waves_per_simd) when waves +* do not use scratch memory and 32 waves (max_scratch_slots_per_cu) +* when they do use scratch memory. This could change for future +* devices and therefore this example should be considered as a guide. +* +* All CU's of a device are available for the process. This may not be true +* under certain conditions - e.g. CU masking. +* +* Finally number of CU's that are occupied by a process is affected by both +* number of CU's a device has along with number of other competing processes +*/ +struct attribute attr_cu_occupancy; };#define qpd_to_pdd (x) container_of(x, struct kfd_process_device, qpd)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +69 -2
114 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ramesh Errabolu
Sent: Tuesday, September 29, 2020 1:27 PM
To: [email protected]
Cc: Errabolu, Ramesh <[email protected]>
Subject: [PATCH 4/4] drm/amd/amdkfd: Surface files in Sysfs to allow users to get number of compute units that are in use.
[Why]
Allow user to know how many compute units (CU) are in use at any given moment.
[How]
Surface files in Sysfs that allow user to determine the number of compute units that are in use for a given process. One Sysfs file is used per device.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 25 +++++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 71 +++++++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +25 -0
@@ -705,6 +705,31 @@ struct kfd_process_device {struct kobject *kobj_stats;unsigned int doorbell_index; + +/* +* @cu_occupancy: Reports occupancy of Compute Units (CU) of a process +* that is associated with device encoded by "this" struct instance. The +* value reflects CU usage by all of the waves launched by this process +* on this device. A very important property of occupancy parameter is +* that its value is a snapshot of current use. +* +* Following is to be noted regarding how this parameter is reported: +* +* The number of waves that a CU can launch is limited by couple of +* parameters. These are encoded by struct amdgpu_cu_info instance +* that is part of every device definition. For GFX9 devices this +* translates to 40 waves (simd_per_cu * max_waves_per_simd) when waves +* do not use scratch memory and 32 waves (max_scratch_slots_per_cu) +* when they do use scratch memory. This could change for future +* devices and therefore this example should be considered as a guide. +* +* All CU's of a device are available for the process. This may not be true +* under certain conditions - e.g. CU masking. +* +* Finally number of CU's that are occupied by a process is affected by both +* number of CU's a device has along with number of other competing processes +*/ +struct attribute attr_cu_occupancy; };#define qpd_to_pdd (x) container_of(x, struct kfd_process_device, qpd) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 17d909c86f50..2807e1c4d59b 100644
drivers/gpu/drm/amd/amdkfd/kfd_process.c +47 -0
52 lines not on this page · raw message
{
@@ -344,6 +390,7 @@ static ssize_t kfd_procfs_queue_show(struct kobject *kobj,
return 0;
}
+
static ssize_t kfd_procfs_stats_show(struct kobject *kobj,
struct attribute *attr, char *buffer) { @@ -359,8 +406,13 @@ static ssize_t kfd_procfs_stats_show(struct kobject *kobj,
PAGE_SIZE,
"%llu\n",
jiffies64_to_msecs(evict_jiffies));
- } else
+
+ /* Sysfs handle that gets CU occupancy is per device */
+ } else if (strcmp(attr->name, "cu_occupancy") == 0) {
+ return kfd_get_cu_occupancy(attr, buffer);
+ } else {
pr_err("Invalid attribute");
+ }
return 0;
}
@@ -466,6 +518,7 @@ static int kfd_procfs_add_sysfs_stats(struct kfd_process *p)
* Create sysfs files for each GPU:
* - proc/<pid>/stats_<gpuid>/
* - proc/<pid>/stats_<gpuid>/evicted_ms
+ * - proc/<pid>/stats_<gpuid>/cu_occupancy
*/
list_for_each_entry(pdd, &p->per_device_data, per_device_list) {
struct kobject *kobj_stats;
@@ -496,6 +549,19 @@ static int kfd_procfs_add_sysfs_stats(struct kfd_process *p)
if (ret)
pr_warn("Creating eviction stats for gpuid %d failed",
(int)pdd->dev->id);
+
+ /* Add sysfs file to report compute unit occupancy */
+ if (pdd->dev->kfd2kgd->get_cu_occupancy != NULL) {
+ pdd->attr_cu_occupancy.name = "cu_occupancy";
+ pdd->attr_cu_occupancy.mode = KFD_SYSFS_FILE_MODE;
+ sysfs_attr_init(&pdd->attr_cu_occupancy);
+ ret = sysfs_create_file(kobj_stats,
+ &pdd->attr_cu_occupancy);
+ if (ret)
+ pr_warn("Creating %s failed for gpuid: %d",
+ pdd->attr_cu_occupancy.name,
+ (int)pdd->dev->id);
+ }
}
err:
return ret;
@@ -537,7 +603,6 @@ static int kfd_procfs_add_sysfs_files(struct kfd_process *p)
return ret;
}
-
void kfd_procfs_del_queue(struct queue *q) {
if (!q)
@@ -909,6 +974,8 @@ static void kfd_process_wq_release(struct work_struct *work)
sysfs_remove_file(p->kobj, &pdd->attr_vram); sysfs_remove_file(p->kobj, &pdd->attr_sdma); sysfs_remove_file(p->kobj, &pdd->attr_evict);
+ if (pdd->dev->kfd2kgd->get_cu_occupancy != NULL)
+ sysfs_remove_file(p->kobj, &pdd->attr_cu_occupancy);
kobject_del(pdd->kobj_stats); kobject_put(pdd->kobj_stats); pdd->kobj_stats = NULL;
--
2.27.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Charish.kasiviswanathan%40amd.com%7C00d660dd712f484026ed08d8649cdb27%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637369972149551613&sdata=Da4vCNUBzXOxuCLmzKy18bi3B3alZGA2qLYq9z33LYY%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx