Skip to contentSkip to conversation

drm/amd/amdkfd: Surface files in Sysfs to allow users to get number of compute units that are in use.

PATCH In review Ramesh Errabolu 2 participants 2 messages Sep 17, 2020 – Sep 19, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 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    |  28 ++++++-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 101 +++++++++++++++++++----
 2 files changed, 114 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +27 -1
index 023629f28495..2ce03586d0dc 100644
@@ -631,7 +631,7 @@ enum kfd_pdd_bound {
 	PDD_BOUND_SUSPENDED,
 };
 
-#define MAX_SYSFS_FILENAME_LEN 11
+#define MAX_SYSFS_FILENAME_LEN 32
 
 /*
  * SDMA counter runs at 100MHz frequency.
@@ -692,6 +692,32 @@ struct kfd_process_device {
 	uint64_t sdma_past_activity_counter;
 	struct attribute attr_sdma;
 	char sdma_filename[MAX_SYSFS_FILENAME_LEN];
+
+	/*
+	 * @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 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 use. 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;
+	char cu_occupancy_filename[MAX_SYSFS_FILENAME_LEN];
 };
 
 #define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +87 -14

141 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
#1 lore raw

drivers/gpu/drm/amd/amdkfd/kfd_process.c static void kfd_sdma_activity_worker(struct work_struct *work) · line 291

Quoted 3 lines · Ramesh Errabolu
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -0
+	if (pdd->qpd.queue_count == 0) {
+		pr_info("%s: Gpu-Id: %d has no active queues for process %d\n",
+			__func__, dev->id, proc->pasid);

pr_debug can be dynamically enabled in dmesg if needed, pr_info will always show in dmesg.

pr_debug("Gpu-Id: %d has no active queues for process %d\n",

		dev->id, proc->pasid);

Philip

Review

Quoted 1 line
(quoted diff) +1 -0
+		return snprintf(buffer, PAGE_SIZE, "%d\n", cu_cnt);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx