History

habanalabs: add uapi to retrieve device utilization

Users and sysadmins usually want to know what is the device utilization as a level 0 indication if they are efficiently using the device. Add a new opcode to the INFO IOCTL that will return the device utilization over the last period of 100-1000ms. The return value is 0-100, representing as percentage the total utilization rate.

Oded Gabbay committed 7 years ago

Commit 75b3cb21 parent 413cf577 files · +222 −23Browse files

Showing the changes to include/uapi (1 of 7 files). Show all

Unified · Split

include/uapi/misc/habanalabs.h+34−15
@@ -77,22 +77,29 @@ enum hl_device_status { · 76 unmodified lines
7777
7878 /* Opcode for management ioctl
7979 *
80− * HW_IP_INFO - Receive information about different IP blocks in the
81− * device.
82− * HL_INFO_HW_EVENTS - Receive an array describing how many times each event
83− * occurred since the last hard reset.
84− * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the
85− * specific context. This is relevant only for GOYA device.
86− * HL_INFO_HW_IDLE - Retrieve information about the idle status of each
87− * internal engine.
80+ * HW_IP_INFO - Receive information about different IP blocks in the
81+ * device.
82+ * HL_INFO_HW_EVENTS - Receive an array describing how many times each event
83+ * occurred since the last hard reset.
84+ * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the
85+ * specific context. This is relevant only for devices
86+ * where the dram is managed by the kernel driver
87+ * HL_INFO_HW_IDLE - Retrieve information about the idle status of each
88+ * internal engine.
8889 * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't
8990 * require an open context.
91+ * HL_INFO_DEVICE_UTILIZATION - Retrieve the total utilization of the device
92+ * over the last period specified by the user.
93+ * The period can be between 100ms to 1s, in
94+ * resolution of 100ms. The return value is a
95+ * percentage of the utilization rate.
9096 */
91−#define HL_INFO_HW_IP_INFO 0
92−#define HL_INFO_HW_EVENTS 1
93−#define HL_INFO_DRAM_USAGE 2
94−#define HL_INFO_HW_IDLE 3
95−#define HL_INFO_DEVICE_STATUS 4
97+#define HL_INFO_HW_IP_INFO 0
98+#define HL_INFO_HW_EVENTS 1
99+#define HL_INFO_DRAM_USAGE 2
100+#define HL_INFO_HW_IDLE 3
101+#define HL_INFO_DEVICE_STATUS 4
102+#define HL_INFO_DEVICE_UTILIZATION 6
96103
97104 #define HL_INFO_VERSION_MAX_LEN 128
98105
@@ -134,6 +141,11 @@ struct hl_info_device_status { · 35 unmodified lines
134141 __u32 pad;
135142 };
136143
144+struct hl_info_device_utilization {
145+ __u32 utilization;
146+ __u32 pad;
147+};
148+
137149 struct hl_info_args {
138150 /* Location of relevant struct in userspace */
139151 __u64 return_pointer;
@@ -149,8 +161,15 @@ struct hl_info_args { · 9 unmodified lines
149161 /* HL_INFO_* */
150162 __u32 op;
151163
152− /* Context ID - Currently not in use */
153− __u32 ctx_id;
164+ union {
165+ /* Context ID - Currently not in use */
166+ __u32 ctx_id;
167+ /* Period value for utilization rate (100ms - 1000ms, in 100ms
168+ * resolution.
169+ */
170+ __u32 period_ms;
171+ };
172+
154173 __u32 pad;
155174 };
156175